focus-trap
Advanced tools
Changelog
6.8.0-beta.0
tabbableOptions
configuration option, which allows specifically for the new getShadowRoot
Tabbable configuration option: focusTrap.createFocusTrap(rootElement, { tabbableOptions: { getShadowRoot: (node) => closedShadowRoot } })
, for example (where your code has the reference to closedShadowRoot
previously created on node
which Tabbable cannot find on its own).v5.3.0-beta.0
Changelog
6.7.1
Changelog
6.7.0
document
option to support focus traps inside <iframe>
elements (#97)setReturnFocus
option to receive a reference to the element that had focus prior to the trap being activated when a function is specified. Additionally, the function can now return false
to leave focus where it is at the time of deactivation. (#485)KeyboardEvent
was not being passed to escapeDeactivates
option when it's a function (#498)initialFocus
option not supporting function returning false
as documented (#490)Changelog
6.6.1
Changelog
6.6.0
281e66c: Add option to allow no initial focus when trap activates via initialFocus: false
There may be cases where we don't want to focus the first tabbable element when a focus trap activates.
Examples use-cases:
In addition, this change ensures that any element inside the trap manually focused outside of focus-trap
code will be brought back in focus if focus is somehow found outside of the trap.
Example usage:
When the trap activates, there will be no initially focused element inside the new trap.
const focusTrap = createFocusTrap('#some-container', {
initialFocus: false,
});
75be463: escapeDeactivates
can now be either a boolean (as before) or a function that takes an event and returns a boolean.
delayInitialFocus
timer created for the second trap before during its activation sequence.Changelog
6.5.1
Changelog
6.5.0
checkCanFocusTrap()
, onPostActivate()
, checkCanReturnFocus()
, and onPostDeactivate()
.SVGElement
as a supported type of "DOM node" since it supports the focus()
method, same as HTMLElement
.Changelog
6.4.0
focus-trap
does not currently leverage the new displayCheck
option.Changelog
6.3.0
clickOutsideDeactivates
can now also be a function that returns a boolean
, similar to allowOutsideClick
. The function receives the MouseEvent
that triggered the click. (#289)