fix: Escape in an open Menu does not trigger tabster actions#36313
Open
layershifter wants to merge 2 commits into
Open
fix: Escape in an open Menu does not trigger tabster actions#36313layershifter wants to merge 2 commits into
layershifter wants to merge 2 commits into
Conversation
📊 Bundle size reportUnchanged fixtures
|
|
Pull request demo site: URL |
bbd0440 to
6e4657c
Compare
A Menu nested in a tabster groupper/modalizer (e.g. a focusMode Card, or a list item whose actions popover shares a modalizer scope with the item) moves focus to the groupper root when Escape closes the menu, instead of restoring focus to the trigger. The MenuPopover keydown handler calls event.preventDefault(), but tabster listens for keydown in the capture phase on the document, so it can't be stopped from the popover handler and still runs its own Escape behaviour (escaping the parent groupper). This is the same problem fixed for react-combobox in microsoft#36275. Fix: add the tabster `focusable.ignoreKeydown: { Escape: true }` attribute on the MenuPopover. The popover only renders while the menu is open, so the attribute is only ever present on an open menu (and Escape still works normally elsewhere) — no need to gate it on the open state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6e4657c to
33c79ca
Compare
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
🕵🏾♀️ visual changes to review in the Visual Change Report
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 2 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default - RTL.submenus open.chromium.png | 404 | Changed |
| vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png | 413 | Changed |
vr-tests-react-components/Positioning 2 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png | 151 | Changed |
| vr-tests-react-components/Positioning.Positioning end.chromium.png | 279 | Changed |
vr-tests-react-components/ProgressBar converged 3 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - Dark Mode.default.chromium.png | 67 | Changed |
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png | 115 | Changed |
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness.default.chromium.png | 117 | Changed |
vr-tests-react-components/TagPicker 1 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png | 677 | Changed |
There were 1 duplicate changes discarded. Check the build logs for more information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Previous Behavior
A
Menunested in a tabster groupper/modalizer (e.g. a Card withfocusMode, or a reaction popover that shares a modalizer id with a parent message groupper) moves focus to the groupper root when Escape closes the menu, instead of restoring focus to the trigger.The
MenuPopoverkeydown handler callsevent.preventDefault()(and the comment intends to stop propagation), but tabster listens forkeydownin the capture phase on the document, so neither prevents tabster's own Escape behaviour from escaping the parent groupper.New Behavior
Adds the tabster
focusable.ignoreKeydown: { Escape }attribute on theMenuPopover, gated on the menu being open — so tabster ignores Escape while the menu handles it to close, and Escape still functions normally when the menu is closed.This is the same fix applied to
react-comboboxin #36275 (useTriggerSlot). It lives on theMenuPopover(rather than the trigger) because for a menu, focus moves into the menu items, and tabster aggregatesignoreKeydownfrom the focused element's ancestors.Related Issue(s)