You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<divrole="dialog" aria-labelledby="modalTitle" aria-describedby="modalDescription"><divid="modalTitle">Save "untitled" document?</div><divid="modalDescription">You have made changes to "untitled.txt" that have not been saved. What do you want to do?</div><buttontype="button">Save changes</button><buttontype="button">Discard changes</button><buttontype="button">Cancel</button></div>
Here are the crib notes:
Add role="dialog" to the Modal root element.
Use aria-labelledby and aria-describedby to point screen readers to the title and body text of the modal.
When the modal is opened, focus on the first tabbable element.
Use JS to trap tabbing within the modal. Add keypress handlers to the first and last tabbable elements so that tabbing from the last element focuses on the first one, and shift-tabbing from the first element focuses on the last one.
Add an ESC keypress handler, so hitting escape closes the modal.
When the modal is closed, use JS to restore focus to the element which was last focused (this should be the button which was clicked to open the modal).
Adding onto here for when we get around to fixing modals: we should also probably upgrade our focus trapping (at least on modals but probably on other things too) to use react-focus-on instead of react-focus-lock which we currently use. (Explanation as to why is in the react-focus-on readme.
Activity
myasonik commentedon Sep 5, 2019
Adding onto here for when we get around to fixing modals: we should also probably upgrade our focus trapping (at least on modals but probably on other things too) to use react-focus-on instead of react-focus-lock which we currently use. (Explanation as to why is in the react-focus-on readme.
chandlerprall commentedon Sep 5, 2019
🤣🎢
For people who don't click through to react-focus-on, it is react-focus-lock plus
[-]Accessibility: Modals[/-][+][EuiModal] Accessibility [/+]chandlerprall commentedon Sep 18, 2020
At least some of the changes mentioned here have been applied, and the rest are now being tracked in #3889