-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Improve the focus management of Modal component #2483
Comments
Is this an issue because there are 2 modals being created?
|
Re: |
Yeah, that means we want the refocusing behavior to be controllable.
I'm also hesitant to suggest adding a prop that React native doesn't have. It seems that focus trap and refocusing behavior only exists on the web. They are very useful most of time, it's just that they really stuck us in a few scenarios, and these requirements also meet the accessibility norms. I had another idea: export a few functions somewhere, for example, add The implementation may be like this: ntdiary@274d344 I fully understand that you may have to consider many factors, so here is just a discussion, and sincerely looking forward to your thoughts. Thanks again for making such a great library. 😄 |
Can we avoid making API changes at this stage by storing a stack of triggers, and refocusing the first that is still connected to the document? |
Thank you for your reply, The above example is just one scenario. I'm afraid this approach can only solve limited scenarios. Perhaps we can just lower its priority first. If other people have similar needs in the future, we can then consider how to do it. : ) |
Is there an existing request?
Describe the feature request
a concise description of the request
Supports setting the focus on the specified element when closing the Modal.
potential solutions
Add a
focusAfterClosed?: ?() => HTMLElement
propadditional context
react-native-web/packages/react-native-web/src/exports/Modal/ModalFocusTrap.js
Lines 142 to 156 in e8098fd
The current code implements Example point 3.
However, in practice, we often also need the focus to be able to return to the specified element. (Return to the trigger element is still the default behavior.)
source: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/dialog/
example.mp4
In this case:
The expected order of focus is:
Add Delivery Address
button -->Street
input -->Add
button -->OK
button -->Add Delivery Address
buttonThe actual order of focus is:
Add Delivery Address
button -->Street
input -->Add
button -->OK
button --> bodyhttps://codesandbox.io/s/focus-order-djuzdk
This issue is from my comment. And the original issue #2175 has been explained in my comments. Maybe that issue could be closed as well?
this commit is trying to implement this feature. If this feature is acceptable, I would improve the docs, tests, and then submit a PR.
The text was updated successfully, but these errors were encountered: