plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
20.95k stars 2.02k forks source link

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

Closed amy-morrill closed 1 day ago

amy-morrill commented 1 year ago

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

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.

alexcjohnson commented 1 year ago

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.

amy-morrill commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

@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) :)

gvwilson commented 1 day ago

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are most important to our community. If this issue is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. (Please note that we will give priority to reports that include a short reproducible example.) If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson