Skip to content

[EuiDataGrid] Add support for copying the focused cell's value with keyboard shortcut only #6561

Description

@davismcphee

We're working on improving copy/paste support for the Discover data grid (elastic/kibana#149525), and we think there's an opportunity to improve general support for it in the EuiDataGrid.

Rather than the user having to manually highlight the entirety of the cell value to copy it, or expanding the cell and highlighting the popover value, both of which can be difficult (especially when there are cell actions or spaces in the text), it would be convenient to offer built-in support for copying the focused cell's value. I believe this should be possible by hooking into the browser's copy event: https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event.

Two notes about this request:

  • It should probably avoid hijacking the copy event if there's actual text highlighted (i.e. the user is trying to copy a partial cell value).
  • It would be preferable if EuiDataGrid also offered support for customizing this behaviour via an onCellCopy callback or similar.

Here's a 10-minute hack job I threw together to demonstrate the concept that can be pasted into the EuiDataGrid docs page or anywhere else containing an EuiDataGrid:

document.addEventListener('copy', (e) => {
  if (document.activeElement.classList.contains('euiDataGridRowCell') && !document.getSelection().toString()) {
    const text = document.activeElement.querySelector('[data-datagrid-cellcontent]').innerText;
    event.clipboardData.setData('text/plain', text);
    event.preventDefault();
    console.log(text);
  }
});

Activity

  1. cee-chen commented on Jan 31, 2023

    @cee-chen
    Contributor

    Hi @davismcphee! We discussed this in our EUI sync today and being able to Ctrl/Cmd+C to copy a cell's value is definitely a cool concept we'd like to support and add to the keyboard shortcuts menu. I strongly agree with your proposal of an onCellCopy API vs us trying to detect cell content via scraping the DOM (although we can certainly attempt to fall back to innerText) - the consumer knows their own data much better than EUI does and is in a better position to customize that for copy purposes.

    As a heads up however, it's currently a medium priority for us, unless you have a use case for multiple teams/products that would bump it to a high. This means we don't currently have an ETA for this - but if you're interested in open source contributing to EuiDataGrid, we'd definitely take a PR on this!

  2. davismcphee commented on Feb 6, 2023

    @davismcphee
    ContributorAuthor

    @cee-chen Thanks for the update, and I'm glad to hear the EUI team agrees that it would be a useful addition! As of right now we don't have an urgent need for the functionality since we at least have a workaround implemented in Discover using a Copy value action, so not giving it a high a priority is totally fine for us. But I'll keep this in mind next time I have some time to work on an EUI contribution and may take it on myself if it's still open 🙂.

  3. jughosta commented on May 22, 2023

    @jughosta
  4. cee-chen commented on May 23, 2023

    @cee-chen
    Contributor

    @jughosta it's not clear to me from those threads whether or not those users are complaining about the ability to use a keyboard shortcut to copy the text, or if said data grid implementations are simply missing a clickable copy cell action entirely.

    This issue is for the former (cmd/ctrl+C to copy) - the latter is up to your team to implement.

  5. jughosta commented on May 23, 2023

    @jughosta
  6. cee-chen commented on May 23, 2023

    @cee-chen
  7. changed the title [-][EuiDataGrid] Add support for copying the focused cell's value[/-] [+][EuiDataGrid] Add support for copying the focused cell's value with keyboard shortcut only[/+] on May 23, 2023
  8. github-actions commented on Nov 20, 2023

    @github-actions

    👋 Hi there - this issue hasn't had any activity in 6 months. If the EUI team has not explicitly expressed that this is something on our roadmap, it's unlikely that we'll pick this issue up. We would sincerely appreciate a PR/community contribution if this is something that matters to you! If not, and there is no further activity on this issue for another 6 months (i.e. it's stale for over a year), the issue will be auto-closed.

  9. added
    stale-issue
    on Nov 20, 2023
  10. davismcphee commented on Mar 27, 2024

    @davismcphee
    ContributorAuthor

    Just bumping this one to prevent staleness since it's still a valuable feature to have 🙂

  11. removed
    stale-issue
    on Mar 27, 2024
  12. cee-chen commented on Mar 27, 2024

    @cee-chen
    Contributor

    Totally agreed - any chance you'd be interested in contributing the feature to EUI? 😄

  13. davismcphee commented on Apr 2, 2024

    @davismcphee
    ContributorAuthor

    I'm definitely interested! Just not sure yet if I'll be able to find time to work on it near term 😅

  14. 3 remaining items

  15. added
    Stale
    on Oct 4, 2024
  16. cee-chen commented on Oct 14, 2024

    @cee-chen
    Contributor

    @davismcphee Our stalebot went rogue and closed this unintentionally - but just curious, would you consider this feature request moot since copying cells directly now works as of #8019? Can we go ahead and leave it closed?

  17. davismcphee commented on Oct 17, 2024

    @davismcphee
    ContributorAuthor

    @cee-chen Thanks for the ping. While #8019 is a great improvement, personally I think this is still a valuable feature for easily copying entire cell values, vs having to manually highlight the text to copy. It seems especially useful for cells with truncated content where it's trickier to select the entire value, and for keyboard users. It's also a common pattern in other data grids I've used, and we've encountered users in Discover with similar expectations.

  18. removed
    Stale
    on Oct 17, 2024
  19. github-actions commented on Sep 24, 2025

    @github-actions

    👋 Hi there - this issue hasn't had any activity in 6 months. If the EUI team has not explicitly expressed that this is something on our roadmap, it's unlikely that we'll pick this issue up. We would sincerely appreciate a PR/community contribution if this is something that matters to you! If not, and there is no further activity on this issue for another 6 months (i.e. it's stale for over a year), the issue will be auto-closed.

  20. added
    stale-issue
    on Sep 24, 2025
  21. davismcphee commented on Sep 25, 2025

    @davismcphee
    ContributorAuthor

    Not stale and still useful.

  22. removed
    stale-issue
    on Sep 25, 2025
  23. added
    request
    on Mar 16, 2026
  24. weronikaolejniczak commented on Aug 14, 2026

    @weronikaolejniczak
    Contributor

    Because it's been raised in SDH, I'll take a look if we can solve this in an easy way inside EUI.

    cc @davismcphee @akowalska622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

data gridrequest

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions