react-spectrum
cbd1daae - Fix #619/RSP-1328 [Accessibility] v2 SubMenu selecting item does not restore focus to Dropdown button (#620)

Commit
6 years ago
Fix #619/RSP-1328 [Accessibility] v2 SubMenu selecting item does not restore focus to Dropdown button (#620) * RSP-1328 [Accessibility] v2 SubMenu selecting item does not restore focus to Dropdown button To reproduce the issue: 1. Open: https://react-spectrum.corp.adobe.com/storybook/iframe.html?id=dropdown–default 2. Press Tab key to navigate to the Dropdown button labelled "Test" 3. Press Space key to expand the Menu. 4. Use ArrowDown to navigate to the SubMenu item. 5. Press ArrowRight to expand the SubMenu. 6. Press Enter or Space to select the focused MenuItem in the SubMenu. 7. The onSelect event will fire, and both the SubMenu and Menu should close. 8. Press Tab then Shift+Tab to verify document focus. Expected behavior: Focus should be restored to the Dropdown trigger button. Actual behavior: Focus is lost to the document.body. Problem seems to be that Dropdown.onMenuSelect, which is called when onSelect is triggered on a Menu, simply hides the OverlayTrigger, and OverlayTrigger hides all Overlays too quickly for the focus to be restored recursively back to the Dropdown button. Possible solution is, in onMenuSelect, to retrieve the rememberedFocus from the OverlayTrigger and restore focus to it if it still exists. * Fix #619/RSP-1328 Refactor by propagating closeOnSelect to SubMenu Per https://github.com/adobe/react-spectrum/pull/620#discussion_r333186192
Author
Michael Jordan
Committer
Parents
Loading