Skip to content

copy to clipboard#306

Merged
severo merged 4 commits intomasterfrom
302-copy-on-ctrl-c
Oct 20, 2025
Merged

copy to clipboard#306
severo merged 4 commits intomasterfrom
302-copy-on-ctrl-c

Conversation

@severo
Copy link
Copy Markdown
Contributor

@severo severo commented Oct 17, 2025

fixes #302

  • copy the stringified content of a cell (even for a custom-rendered cell)
  • copy the selection, if any
  • don't copy if the cell is empty
Screencast.From.2025-10-17.17-48-20.mp4

I still have a bug that I don't understand... Possibly not related to the clipboard, but I just noticed in this PR: when I focus outside of the app, then when I click a row header or a column header, it gets the focus (as far as I could check), but the copy event is done on the last focused cell, not the new one. I don't get why yet.

Screencast.From.2025-10-17.17-50-07.mp4

@severo severo marked this pull request as draft October 17, 2025 15:56
@severo
Copy link
Copy Markdown
Contributor Author

severo commented Oct 20, 2025

It seems to be related to the CSS property we use on the column and row headers:

user-select: none;

In this case, Ctrl+C does not target the cell, and the last targeted cell will be used. I guess it's because it's the one that contains the document "selection".

Also, see https://developer.mozilla.org/en-US/docs/Web/API/Selection#selection_and_input_focus and https://developer.mozilla.org/en-US/docs/Web/API/Selection#behavior_of_selection_api_in_terms_of_editing_host_focus_changes. The relation between focus and selection is not totally standard across browsers.

I think the most acceptable solution for now is to allow selecting text in column and row headers, so that the cells can be copied.

wdyt @platypii?

@severo severo marked this pull request as ready for review October 20, 2025 13:52
…he copy is on another cell"

This reverts commit 6132aae.
@severo
Copy link
Copy Markdown
Contributor Author

severo commented Oct 20, 2025

Note that I reverted the first solution I tried, that was not a good fix at all: 6132aae. It was the reason of the previous test failure.

@severo severo requested a review from platypii October 20, 2025 14:18
Copy link
Copy Markdown
Contributor

@platypii platypii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is great for quick copying of data (eg- to paste into chatgpt).

I agree with removing user-select: none from the headers. First of all, sometimes I do want to be able to copy that header text. Also we don't need to be so opinionated about that css: let downstream users decide if its selectable or not.

@severo severo merged commit 25a43e6 into master Oct 20, 2025
5 checks passed
@severo severo deleted the 302-copy-on-ctrl-c branch October 20, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl-C should copy selected cell

2 participants