Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid focus fighting when a datagrid cell content has its own popover #3951

Merged

Conversation

chandlerprall
Copy link
Contributor

@chandlerprall chandlerprall commented Aug 21, 2020

Summary

Fixes #3790 and fixes #3509

Datagrid cells containing a single interactive element will shift received focus to that element. When that single element is a button that triggers a popover, the popover steals (and traps) focus. React propagates popover's focus event up through the portal back to the owning cell which then shifts focus to its interactive element, then the popover focus trap takes the focus back, triggering a new focus event.

This changes the datagrid cell's logic to only shift focus to its interactive element if it is the wrapping element receiving the focus in the first place, avoiding the issue with React bubbling events through portals.

I built EUI with this change and tested it in the project provided in #3509, confirming that it resolves the focus fighting issue too. There is still rendering performance issues when opening EuiModal inside EuiModal inside EuiModal, as the browser has to work extra hard during re-layouts, but that is not related to the data grid

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes

  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
    - [ ] Props have proper autodocs
    - [ ] Added documentation
  • Checked Code Sandbox works for the any docs examples
    - [ ] Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3951/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3951/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Just the one question. Code changes LGTM!

src-docs/src/i18ntokens.json Outdated Show resolved Hide resolved
@chandlerprall chandlerprall force-pushed the bug/3790-datagrid-focus-trapping branch from 0876e71 to e231ab6 Compare August 24, 2020 18:27
@chandlerprall chandlerprall force-pushed the bug/3790-datagrid-focus-trapping branch from e231ab6 to 293da25 Compare August 24, 2020 18:28
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3951/

@chandlerprall chandlerprall merged commit b592a15 into elastic:master Aug 24, 2020
@chandlerprall chandlerprall deleted the bug/3790-datagrid-focus-trapping branch August 24, 2020 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data grid focus fighting DataGrid in Modal performance
3 participants