- 694e2fa: Package main/module entries no longer point to minified bundles.
- Add boolean value support for
allowOutsideClick
option. - New
preventScroll
feature to prevent scrolling to the element getting focus if not in the viewport. - Changed code formatting to use dangling commas where ES5 supports them.
- BREAKING: Updated tabbable dependency to the new 5.0.0 release which contains breaking changes to its
isTabbableRadio()
internal function. - Help with tree shaking by having
package.json
statesideEffects: false
to mark this module as having no side effects as a result of merely importing it. - BREAKING: This
package.json
's "main" no longer points to./index.js
in the package (although it still points to a CJS module, so it's possible this actually doesn't break anything). It now has:- "main":
dist/focus-trap.min.js
(the CJS bundle) - "module":
dist/focus-trap.esm.min.js
(the new ESM bundle) - the UMD is
dist/focus-trap.umd.min.js
if needed (convenient for loading directly in an older browser that doesn't support ESM) - NOTE: The CJS build no longer provides a function as a default export. Use
const { createFocusTrap } = require('focus-trap');
to get the function from before. - NOTE: The ESM build does not provide a default export. Use
import { createFocusTrap } from 'focus-trap';
to import the module.
- "main":
- New ESM Build: Included in
dist/focus-trap.esm.*
. - New UMD Build: Included in
dist/focus-trap.umd.*
.
- Add
setReturnFocus
option that allows you to set which element receives focus when the trap closes.
- Add
allowOutsideClick
option that allows you to pass a click event through, even whenclickOutsideDeactivates
isfalse
.
- Update Tabbable to improve performance (see Tabbable's changelog).
- Breaking (kind of): if the
onActivate
callback changes the list of tabbable nodes and theinitialFocus
option is not used, the initial focus will still go to the first element present before the callback. - Improve performance of activating a trap.
- Register document-level event listeners as active (
passive: false
).
- Fix reference to root element that caused errors within Shadow DOM.
(Release 4.0.1 was a mistake, containing no changes.)
- Breaking (kind of): Focus trap now manages a queue of traps, so when a trap is paused because another trap activates, it will be unpaused when that other trap deactivates. If Trap A was automatically paused because Trap B activated (existing behavior), when Trap B is deactivated Trap A will be automatically unpaused (new behavior).
- Breaking (kind of): Update Tabbable to detect more elements and be more careful with radio buttons (see Tabbable's changelog).
- Breaking (kind of): If
clickOutsideDeactivates
andreturnFocusOnDeactivate
are bothtrue
, focus will be returned to the pre-trap element only if the clicked element is not focusable.
- Add slight delay before moving focus to the first element in the trap. This should prevent an occasional bug caused when the first element in the trap will close the trap if it picks up on the event that triggered the trap's opening.
- Fix
"main"
field inpackage.json
.
- Publish UMD build so people can download it from
unpkg.com
.
- Fixed: TypeScript signature for
activate
function.
- Added: TypeScript declaration file.
- Fixed: Activation does not re-focus already-focused node.
- Fixed: Tabbing works as expected when initially focused Node has a negative
tabindex
and is in the middle of other tabbable elements.
- Added:
initialFocus
andfallbackFocus
options can take functions that return DOM nodes. - Fixed:
pause
andunpause
cannot accidentally add extra event listeners.
- Added/fixed, depending on your perspective: If focus is already inside the focus trap when it is activated, leave focus where it is instead of forcing it to the first tabbable node or
initialFocus
.
- Added:
fallbackFocus
option.
- Fixed:
clickOutsideDeactivates
no longer triggers deactivation when you click inside the trap.
- Fix bug when activating multiple focus traps.
- Rewrote the thing, altering the API. Read the new docs please.
- Update
tabbable
to fix handling of traps with changing contents.
- Improve
clickOutsideDeactivates
functionality.
- Add
clickOutsideDeactivates
option. - Add
escapeDeactivates
option.
- Make sure to
select()
<input>
elements when they receive focus via tab.
- Fix buggy attempts to focus nodes that don't exist.
- Initial release.