This example shows a layout that includes a focus trap. You cannot navigate into the trap using arrows. Instead, you must navigate to the button that says "Select to move into Trap" and press the Enter key on your keyboard or remote.
Similarly, you cannot leave the focus trap by navigating with arrows. To exit, you must move focus to the button that says "Return" and press Enter.
- Clone this repository
- Navigate into this directory
- Run
npm install - Run
npm start
The example will be running at localhost:3000.
- The
isTrapprop, which creates a focus trap - The
forgetTrapFocusHierarchyprop, which makes it so that re-entering the trap does not preserve the previous hierarchy. - The
useSetFocushook to imperatively set the focus