Skip to content

API Reference: initiateFocusTrap

James edited this page Mar 8, 2022 · 2 revisions

initiateFocusTrap is a helpful method, that you may wish to make use of outside of your modal. It allows you to restrict the users keyboard navigation to only the children of a specific DOM node. This is helpful when you want the user to focus on a specific set of information in-order to make a decision.

In the case of a modal, it would be pretty useless if the user is navigating by keyboard, and we allow them to interact with elements that are not even relevant to the action required in the modal.

initiateFocusTrap takes one parameter which is the id of the parent element you wish to trap the user inside of.

parameter name Description Type Default value
parentId The id of the DOM element you wish to trap the users focus inside of. string null

Clone this wiki locally