Nikku/jquery-bootstrap-scripting — Issue #30: Tab key navigation restriction
Author: Jito
Created: 2012-02-24 22:35:27+00:00
State: open

When the modal is opened, if you press `Tab` or `Shift + Tab` you can focus all the underlying elements.

From a UX point of view, if the purpose of a modal is to **catch** the user's attention and get *something* resolved through an action, so it would be extremely useful to restrict the tab key navigation to the focusable elements of the modal.

A quick approach to the logic behind it could be:

1. Listen to the `keydown` event in the modal DOM element (childs will bubble up)
2. Check each time that the focused element is one of the modal's children
3. If it's not, return focus to the first focusable element (link, input or button)