Skip to content

[EuiPopover] Support custom onClickOutside overrides#6500

Merged
cee-chen merged 5 commits intoelastic:mainfrom
cee-chen:popover-cancel-close
Dec 22, 2022
Merged

[EuiPopover] Support custom onClickOutside overrides#6500
cee-chen merged 5 commits intoelastic:mainfrom
cee-chen:popover-cancel-close

Conversation

@cee-chen
Copy link
Copy Markdown
Contributor

@cee-chen cee-chen commented Dec 22, 2022

Summary

closes #6498

It appears the Lens team wants the ability to add a confirmation modal on EuiPopover outside click, in order for consumers to not lose progress or input if they accidentally click away/outside of the popover before finishing their action within the popover.

This is currently not supported by EuiPopover via closePopover (and cannot be). Instead, we need to modify focusTrapProps to support overriding our internal popover onOutsideClick method, which then will allow a consumer to toggle a confirmation modal manually:

screencap

QA

  • Go to https://eui.elastic.co/pr_6500/#/layout/popover#custom-outside-click-behavior
  • Click to open the popover, and then click outside the popover
  • Confirm that a confirmation modal appears
  • Confirm that clicking "Yes" causes the confirmation modal and the popover to appear
  • Confirm that clicking "No" causes the confirmation modal to disappear, but the popover is still in its open state
  • Confirm that focus is still trapped within the originating popover on modal close, and that attempting to close the modal again re-triggers the confirmation modal

General checklist

  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Added or updated **jest and cypress tests**
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

- [ ] Checked in both light and dark modes
- [ ] Checked Code Sandbox works for any docs examples
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Updated the Figma library counterpart

…peKey`

- enabling consumers to not automatically close the popover, but instead (e.g.) trigger a confirmation that can keep the popover open
@cee-chen cee-chen requested a review from 1Copenut December 22, 2022 19:35
@kibanamachine
Copy link
Copy Markdown

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

@cee-chen cee-chen changed the title [EuiPopover] Support custom onClickOutside and onEscapeKey overrides [EuiPopover] Support custom onClickOutside overrides Dec 22, 2022
@cee-chen cee-chen enabled auto-merge (squash) December 22, 2022 21:09
@cee-chen cee-chen disabled auto-merge December 22, 2022 21:10
@cee-chen cee-chen enabled auto-merge (squash) December 22, 2022 21:10
@kibanamachine
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

@1Copenut 1Copenut 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 tested locally for keyboard navigation with Esc key, and on VoiceOver with Safari and Firefox. I explored the keyboard navigation UX vs. mouse click UX with the screen reader turned on.

@cee-chen and I agree pressing ESC to close a modal is well-established for keyboard and screen reader users, so we opted not to allow that to be overridden. The cost of breaking that contract felt too high.

Allowing for a confirmation modal on outside click feels like a good way to avoid unsaved work while maintaining the UX contract for keyboard navigation.

@cee-chen cee-chen merged commit 088af6c into elastic:main Dec 22, 2022
@cee-chen cee-chen deleted the popover-cancel-close branch December 22, 2022 21:43
1Copenut added a commit to elastic/kibana that referenced this pull request Jan 4, 2023
## Summary

`eui@72.0.0` ⏩ `eui@72.1.0`

---
## [`72.1.0`](https://github.com/elastic/eui/tree/v72.1.0)

- Changed design of empty ranges in `EuiColorStops` to have diagonal
gray stripes instead of a solid light gray color
([#6489](elastic/eui#6489))
- Changed popover in `EuiColorStops` to not appear when dragging/moving
a color stop ([#6489](elastic/eui#6489))
- `EuiPopover` now supports overriding `focusTrapProps.onClickOutside`,
which allows customization of auto-close behavior on outside click.
([#6500](elastic/eui#6500))

**CSS-in-JS conversions**

- Converted `EuiColorStops` to Emotion
([#6489](elastic/eui#6489))
- Added `brighten` service to manipulate CSS-in-JS colors
([#6489](elastic/eui#6489))
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.

[EuiPopover] Click outside is not called twice on click out of popover.

3 participants