FlexGrid: Menu appears when pasting cell values in safari

Posted by: matt_baker on 7 April 2021, 9:52 am EST

    • Post Options:
    • Link

    Posted 7 April 2021, 9:52 am EST - Updated 3 October 2022, 5:05 am EST

    This seems to be affecting macOS Big Sur / Safari 14:

    When pasting a value into a cell, a small context menu appears with “Paste” inside. Clicking or ignoring the menu still pastes the value, but the menu shouldn’t appear, and does not appear in Big Sur / Chrome.

    Is this a known Safari issue, and is there a workaround for removing / preventing the menu from appearing?

  • Posted 7 April 2021, 9:14 pm EST

    Hi,

    This is the expected behavior. In safari, as a security feature, when document.execCommand(“paste”) command is executed then a context menu is shown to the user to confirm if they want to paste i.e allow the website to read clipboard content or not. You may confirm this behaviour using the following sample:

    https://codesandbox.io/s/wijmo-starter-forked-fyvw4?file=/src/index.js

    In the sample, try to paste in input field using by pressing the command + v key and observe that “paste” menu is displayed.

    Regards

  • Posted 17 April 2021, 12:10 am EST

    Other spreadsheet-like web applications (Quip, Google Spreadsheets, ag-grid) allow copy/paste of cell values without the menu appearing. Is it an implementation issue? Would moving to the Async Clipboard API solve it?

  • Posted 17 April 2021, 12:39 pm EST

    From the demo provided, it appears that the menu item doesn’t show up when using Edit > Paste; it does when using cmd+V in this case because the page is preventing the key event (which prevents the paste command), and then programmatically triggers a paste.

    I assume that other libraries do not follow this pattern, and so the menu does not appear.

  • Posted 18 April 2021, 6:37 pm EST

    I’m not exactly sure how other libraries implement this, but ye moving to ClipboardAPI would fix this.

    then programmatically triggers a paste

    Yes indeed, the paste menu is displayed when programmatically triggering paste command using the execCommand method.

    Wijmo has not moved to clipboard API because it is still fairly new, also IE doesn’t support this API. If you are interested then you may use Clipboard API to read the clipboard text and then use the setClipString method of the flexgrid to perform paste.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels