react-spectrum
react-spectrum copied to clipboard
fix(#3128): useDialog autoFocus behavior fails in Storybook example for Modal unmounting trigger example
- Make sure that Dialog autoFocus actually happens.
- Add workaround for focus management on close within the Storybook example until #2445 is approved.
Closes #3128
โ Pull Request Checklist:
- [x] Included link to corresponding React Spectrum GitHub Issue #3128 .
- [x] Added/updated unit tests and storybook for this change (for new code or code which already has tests).
- [x] Filled out test instructions.
- [ ] Updated documentation (if it already exists for this component).
- [x] Looked at the Accessibility Practices for this feature - Aria Practices
๐ Test Instructions:
- Open chrome://settings/accessibility and enable "Show a quick highlight on the focused object."
- Open https://reactspectrum.blob.core.windows.net/reactspectrum/87cd3d786ab7a2b7be3524e0cb3b96dc301a6feb/storybook/index.html?path=/story/modal--unmounting-trigger
- Tab to focus the Open Popover button within the Storybook example.
- Press Space key to open the Popover
- Chrome's focus highlight should render around the Popover dialog itself.
- Tab to focus the Open modal button within the Popover.
- Press Space key to open the Modal
- The Popover will close in the background.
- Chrome's focus highlight should render around the modal Dialog that opens to replace the Popover when the Dialog receives focus.
- Press Tab to focus, then Space to activate, the "Close" CTA button, or press Escape key to close the Modal.
- The modal will close.
- Focus should be explicitly restored the the Open Popover button. (Note that this explicit focus management is only necessary until #2445 gets accepted and merged.)
๐งข Your Project:
Adobe/Accessibility
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
With the comment made with https://github.com/adobe/react-spectrum/pull/2445#issuecomment-1150536157, I think the fix we'll want to implement is to prevent focus from moving to a closed scope's previously focused node if a sibling or child scope has focus within it now. Perhaps we want to wait for the refactor mentioned in https://github.com/adobe/react-spectrum/pull/2445#issuecomment-1150536157 to take place before trying to fix the current issue?
With the comment made with #2445 (comment), I think the fix we'll want to implement is to prevent focus from moving to a closed scope's previously focused node if a sibling or child scope has focus within it now. Perhaps we want to wait for the refactor mentioned in #2445 (comment) to take place before trying to fix the current issue?
I think the Dialog autoFocus behavior change is a legitimate fix for this issue without having to wait for a more significant refactoring of FocusScope.
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐
Build successful! ๐