dash icon indicating copy to clipboard operation
dash copied to clipboard

[BUG]: Dash-Table unexpected behavior when copying and pasting double quotes

Open amy-morrill opened this issue 3 years ago • 4 comments

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.

amy-morrill avatar Aug 08 '22 20:08 amy-morrill

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.

alexcjohnson avatar Aug 09 '22 22:08 alexcjohnson

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.

amy-morrill avatar Aug 10 '22 16:08 amy-morrill

@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? Screen Shot 2022-08-15 at 10 09 59 AM Screen Shot 2022-08-15 at 10 11 17 AM

amy-morrill avatar Aug 15 '22 15:08 amy-morrill

@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? Screen Shot 2022-08-15 at 10 09 59 AM Screen Shot 2022-08-15 at 10 11 17 AM

Solved -- I didn't realize that I had to fork the dash repo before cloning. Just submitted a PR for this (#2202) :)

amy-morrill avatar Aug 22 '22 19:08 amy-morrill