-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(react-popover): Stop propagation when closing the PopoverSurface with Escape #27832
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
fix(react-popover): Stop propagation when closing the PopoverSurface with Escape #27832
Conversation
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 989ead3c07d6df61441f9c6ca8102634e40dc48d (build) |
📊 Bundle size reportUnchanged fixtures
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 001e09d:
|
Perf Analysis (
|
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| InfoButton | mount | 21 | 22 | 5000 | Possible regression |
All results
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| Avatar | mount | 706 | 710 | 5000 | |
| Button | mount | 381 | 392 | 5000 | |
| Field | mount | 1305 | 1303 | 5000 | |
| FluentProvider | mount | 946 | 944 | 5000 | |
| FluentProviderWithTheme | mount | 121 | 130 | 10 | |
| FluentProviderWithTheme | virtual-rerender | 105 | 112 | 10 | |
| FluentProviderWithTheme | virtual-rerender-with-unmount | 113 | 113 | 10 | |
| InfoButton | mount | 21 | 22 | 5000 | Possible regression |
| MakeStyles | mount | 1111 | 1145 | 50000 | |
| Persona | mount | 2036 | 2044 | 5000 | |
| SpinButton | mount | 1601 | 1602 | 5000 |
🕵 fluentuiv9 No visual regressions between this PR and main |
|
I'm not sure if stop propagation is ideal (although we're already doing exactly that everywhere apparently 🤷🏼♂️). This brings me the question if we shouldn't have a global context to indicate which component is currently responsible to react for such events 🤔. WDYT @ling1726? |
|
Seems to be related to having a focusable element inside the https://codesandbox.io/s/reverent-booth-8l2w1j?file=/example.tsx |
packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts
Outdated
Show resolved
Hide resolved
packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts
Outdated
Show resolved
Hide resolved
bsunderhus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's prevent default instead of stopping propagation as followed in the discussion: https://github.com/microsoft/fluentui/pull/27832/files#r1193611849
WDYT @sopranopillow ?!
|
Hey, sorry to answer until now @bsunderhus @ling1726,
sounds good, looks like it is the way to go, but this is a Dialog focused solution. I'll talk to Sarah about her thoughts on how we should handle propagation and such, but the data attribute sounds promising. I've created this issue to keep track of working on that. As a side note: there's a bug with tabster where having the popover inside the dialog and closing it (with the preventDefault) refocuses to the Dialog's trigger and not the Popover's trigger. So in case you're testing this and see that happening, that's the reason why. It's due to tabster not keeping/not working correctly with a focus queue to go back to the previous trigger. |
|
🎉 Handy links: |
|
🎉 Handy links: |

Previous Behavior
When Popover was used inside a Dialog component (note Popover has to be nested) and you press escape to close the Popover, the Dialog is closed along with PopoverSurface.
New Behavior
Stop Propagation to avoid closing the parent Dialog.