Avoid focus fighting when a datagrid cell content has its own popover #3951
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 newfocus
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- [ ] Props have proper autodocs- [ ] Added documentation- [ ] Added or updated jest tests