Open ned2 opened 2 years ago
I did a bit of digging and it looks like the issue is that the onCopy
event handler in dash-table/components/ControlledTable/index.tsx
makes the assumption that the DataTable is in cell_selectable=True
mode, as it always defers to TableClipboardHelper.toClipboard
, which takes data from its selectedCells
param, however this will always be empty when cell_selectable=False
.
I'm wondering if what's needed is for the copy event handling logic to opt-out of using the DataTable's copying machinery and defer to the browser's default handling?
@alexcjohnson is this something we could address with a relatively small change? If so I'd be up for trying to put together a PR. Or is this opening a broader question that needs untangling first?
@ned2 thanks for the investigation! (and apologies for the slow reply, this came in during a vacation and then slipped off my radar π ) I think you're right that these events should just revert to the browser when cell_selectable=False
. And if this is easy to change, by all means go for it!
@ned2 thanks for your hints, I have created a pull request that solves this issue: https://github.com/plotly/dash/pull/2114
@alexcjohnson I'd be very happy to get some feedback on it from you, particularly since this is my first PR for dash π
Will copy/paste of partial cell content be fixed with this PR too, or will it still be a separate issue?
@AnnMarieW the fix from the PR will only affect copy/paste behavior in situations where no cell has been selected, so I assume it will not (completely) fix the issue you mentioned.
However, feel free to try it out yourself: the fix has already been included in the latest dash release π
Describe the bug
When a
DataTable
is initialised withcell_selectable=False
, text cannot be copied to the clipboard. This is independent of the issue in #1975 where cells in columns withpresentation
value ofinput
do not appear to be visually selected. The text can actually be selected, however when attempting to copy the selection, nothing is added to the clipboard.Expected behavior When
cell_selectable
is false, text selected inside DataTable cells should be able to be copied to the clipboard as is normally handled by the browser.Minimal Example Text in any cell (regardless of
presentation
) cannot be copied to the clipboard.Environment