react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

fix(#3128): useDialog autoFocus behavior fails in Storybook example for Modal unmounting trigger example

Open majornista opened this issue 3 years ago โ€ข 16 comments

  1. Make sure that Dialog autoFocus actually happens.
  2. 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:

  1. Open chrome://settings/accessibility and enable "Show a quick highlight on the focused object."
  2. Open https://reactspectrum.blob.core.windows.net/reactspectrum/87cd3d786ab7a2b7be3524e0cb3b96dc301a6feb/storybook/index.html?path=/story/modal--unmounting-trigger
  3. Tab to focus the Open Popover button within the Storybook example.
  4. Press Space key to open the Popover
  5. Chrome's focus highlight should render around the Popover dialog itself.
  6. Tab to focus the Open modal button within the Popover.
  7. Press Space key to open the Modal
  8. The Popover will close in the background.
  9. Chrome's focus highlight should render around the modal Dialog that opens to replace the Popover when the Dialog receives focus.
  10. Press Tab to focus, then Space to activate, the "Close" CTA button, or press Escape key to close the Modal.
  11. The modal will close.
  12. 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

majornista avatar May 27 '22 16:05 majornista

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?

LFDanLu avatar Jun 09 '22 19:06 LFDanLu

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.

majornista avatar Jun 09 '22 19:06 majornista