Skip to content

[EuiDataGrid] Fix cell popover close on cell click unintentionally affecting complex cell popovers#5797

Merged
cee-chen merged 4 commits intoelastic:mainfrom
cee-chen:kibana/128626
Apr 15, 2022
Merged

[EuiDataGrid] Fix cell popover close on cell click unintentionally affecting complex cell popovers#5797
cee-chen merged 4 commits intoelastic:mainfrom
cee-chen:kibana/128626

Conversation

@cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Apr 14, 2022

Summary

This PR essentially reverts the approach used in #5681 as it is causing the Security team unintentional headaches/bugs, detailed in elastic/kibana#128626 (comment).

This PR will need to be backported to v53.0.2 and then further backported to Kibana's 8.2 branch before the next BC.

Checklist

- [ ] Checked in both light and dark modes
- [ ] Checked in mobile onFocus should work for tap events as well
- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for any docs examples
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Updated the Figma library counterpart
- [ ] Checked for accessibility including keyboard-only and screenreader modes Applies to mouse clicks only, not possible to focus originating cell without popover already having been closed otherwise

  • Checked in Chrome, Safari, Edge, and Firefox
  • Added or updated jest and cypress tests
  • A changelog entry exists and is marked appropriately

- in a more targeted manner that doesn't affect popovers with complex focus children (e.g. modals, nested popovers)
@cee-chen cee-chen added this to the Elastic Stack 8.2 milestone Apr 14, 2022
@cee-chen cee-chen marked this pull request as ready for review April 14, 2022 20:33
@kibanamachine
Copy link

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

@cee-chen
Copy link
Contributor Author

jenkins test this

@cee-chen
Copy link
Contributor Author

Testing this a backported version of this now against 8.2 Kibana to confirm that it fixes elastic/kibana#128626

Comment on lines +401 to +404
// Close the cell popover if the popover was open and the user clicked the cell
if (this.props.popoverContext.popoverIsOpen) {
this.props.popoverContext.closeCellPopover();
}
Copy link
Contributor

@thompsongl thompsongl Apr 14, 2022

Choose a reason for hiding this comment

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

Based on the comment, should this be in onClick instead of onFocus? Or is onFocus an analog for a click event in the context of a data grid cell?

Copy link
Contributor Author

@cee-chen cee-chen Apr 14, 2022

Choose a reason for hiding this comment

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

Each data grid cell is clickable/focusable so onFocus will also fire on clicks. I don't think it's super necessary to specify a separate onClick event - in theory the only realistic way that a user could focus the cell while the popover is open is through either clicking or tapping the cell (keyboard users should not be able to exit the popover in theory, but it is possible if the focus trap has been broken).

I'm also bogarting the existing onFocus event because it has a nice event.target check that I also want for this behavior (i.e. only firing on the cell parent and not on cell children focus).

tl;dr there's no real downside to using onFocus, it's broader and will catch more possible side effects/users, even if the main use case is mouse clicks

Copy link
Contributor

Choose a reason for hiding this comment

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

in theory the only realistic way that a user could focus the cell while the popover is open is through either clicking or tapping the cell

That's kind of what I was thinking too. Sounds good

@cee-chen
Copy link
Contributor Author

I can also confirm this is now working on Kibana 8.2:

screencap

@kibanamachine
Copy link

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

- because I put the new logic inside the setTimeout, Cypress was opening the popover too quickly and the new logic was instantly closing it *derp*

- the new logic probably doesn't need to be in a timeout, so moving it out
@kibanamachine
Copy link

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

@cee-chen
Copy link
Contributor Author

@thompsongl @chandlerprall would love to get this merged in and backported today if y'all have some time to review! 🙏 Last BC is next Wednesday so we are on a small timeline

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.

LGTM

I'm good with the backport strategy unless @chandlerprall would rather have the security team adjust their architecture.

@cee-chen
Copy link
Contributor Author

Based on their latest response in elastic/kibana#128626 I don't think that's realistic, but we can always re-revert in main later on for future majors.

@chandlerprall
Copy link
Contributor

chandlerprall commented Apr 15, 2022

Good to go with the proposed backport(s)!

@cee-chen cee-chen merged commit d948e5e into elastic:main Apr 15, 2022
@cee-chen cee-chen deleted the kibana/128626 branch April 15, 2022 15:56
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.

4 participants