dash
dash copied to clipboard
[BUG]: Dash-Table unexpected behavior when copying and pasting double quotes
Hi Dash team! I'm hoping to get some help with a bug I found in dash-table.
The Bug: In my application, users copy and paste data into a dash-table, and some of this data includes two consecutive double quotes. However, when copied and pasted into the table, the consecutive double quotes are automatically changed to be one double quote (e.g.: a""b becomes a"b). This is especially hard to fix because some data also contains one double quote (e.g.: a"b could be a valid input).
The Expected Behavior: Strings copied and pasted into dash-table cells should not be changed i.e. any consecutive double quotes in a string should not be converted to one double quote.
My Context:
dash 2.0.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
- OS: macOS Monterey; version 12.4
- Browser: Google Chrome; version 103.0.5060.134
Thank you for your help!! I also would be happy to try to contribute to solving this, although I'm a bit unsure of where to start.
Thanks for the report @amy-morrill - this is strange behavior indeed!
It looks like it's coming from sheetclip - specifically SheetClip.prototype.parse here:
https://github.com/plotly/dash/blob/e746bdbbac5a3581a6cac7ba0431ef03bf7859b5/components/dash-table/src/dash-table/utils/TableClipboardHelper.ts#L101
Sheetclip is an essentially abandoned package - and in fact the exact issue you identified has been open for nearly a decade https://github.com/warpech/sheetclip/issues/4. So I imagine the way to fix it will be to either find an alternative package that does the same things but without this problem, fork sheetclip and fix the problem there, or inline it into the dash-table codebase and fix the problems there. I'd probably vote for inlining it unless there's an obvious alternative package. What all the package is doing I'm not sure, but dash-table has pretty extensive tests - for example clipboard_test.ts, test_basic_copy_paste.py, and test_markdown_copy_paste.py so if they all pass that should suffice, and a new test or two in those files would cement whatever is done to fix this.
Thank you so much for pointing me in the right direction @alexcjohnson! I'm really excited to start working on this -- I agree with you that the inline strategy makes the most sense, so I'm going to start with that.
@alexcjohnson not sure if this is the right place to ask this, but I'm having some trouble pushing the branch I created to the plotly/dash repository. Do I need to be added as a contributor before I can do this? If not, do you have any ideas about what might be going wrong?

@alexcjohnson not sure if this is the right place to ask this, but I'm having some trouble pushing the branch I created to the plotly/dash repository. Do I need to be added as a contributor before I can do this? If not, do you have any ideas about what might be going wrong?
![]()
Solved -- I didn't realize that I had to fork the dash repo before cloning. Just submitted a PR for this (#2202) :)