react-datasheet icon indicating copy to clipboard operation
react-datasheet copied to clipboard

Paste not working in IE

Open mdanielcristian opened this issue 6 years ago • 5 comments

Paste is not working in IE. The onCellsChanged and parsePaste handlers are not triggered

Repro even on official site: https://nadbm.github.io/react-datasheet/

mdanielcristian avatar Apr 10 '18 13:04 mdanielcristian

After a bit more digging I found why it isn't working. On chrome, the paste event is triggered every time you paste on the document. In ie, it first checks if the focus is on an input element and if so, it triggers the event, if not the event is not triggered. Since when you first click on a cell you are on a div (not an input) the paste event is not triggered. I have a quick fix, not the best, but it seems to work from the limited testing I had time to do:

line 507 in DataSheet.js, replace the document.addEventListener('paste', this.handlePaste); with image

this checks if is ie, then use the on key down event and if the key combination is Ctrl + V that call the paste function with the clipboard data that you can take from the window.

If there is a better solution, please let me know.

mdanielcristian avatar Apr 11 '18 13:04 mdanielcristian

Ideally I would love to avoid detectIE in the code, truth be told, I did not test with IE. I will keep this open for anyone looking to make this work in IE .

nadbm avatar Apr 13 '18 19:04 nadbm

:+1:

souppower avatar May 25 '18 08:05 souppower

@mdanielcristian, thanks for your solution. I have tried your solution but unfortunately, this does not seem to be working anymore. I am thinking that changing in version would be one reason. I will try to edit some of my DataSheet.js to get copy and paste works in ie. However, if you have already done it, can you share?

SapiensTechnology avatar Aug 08 '18 00:08 SapiensTechnology

@nadbm I was checking in on the status of this issue, and saw #162. I think I speak for many people when I say thank you for getting this resolved! Can this issue be closed?

tmreay avatar Mar 24 '20 08:03 tmreay