react-datasheet
react-datasheet copied to clipboard
Paste not working in IE
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/
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
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.
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 .
:+1:
@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?
@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?