emulsify-ds / compound

Compound is the default component collection for Emulsify
https://emulsify-ds.github.io/compound/
GNU General Public License v2.0
12 stars 12 forks source link

feat: add keyboard trap to modal for ada compliance #36

Closed ryanhagerty closed 2 years ago

ryanhagerty commented 2 years ago

Summary This adds a keyboard trap when the modal is open so that the component can be ADA WCAG 2.0 compliant.

When a user opens a modal, this will keep all keyboard focusable elements inside the modal. The reason for this is that a keyboard user may open a modal and tab to content that is outside the modal and therefore not accessible.

From an example of success criterion in the WCAG 2.0 guidelines:

A modal dialog box

A Web application brings up a dialog box. At the bottom of the dialog are two buttons, Cancel and OK. When the dialog has been opened, focus is trapped within the dialog; tabbing from the last control in the dialog takes focus to the first control in the dialog. The dialog is dismissed by activating the Cancel button or the OK button.

How to review this PR