@y14e/roving-tabindex 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,14 +10,14 @@ npm i @y14e/roving-tabindex
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import { createRovingTabIndex } from '@y14e/roving-tabindex@2.0.4';
13
+ import { createRovingTabIndex } from '@y14e/roving-tabindex@2.0.6';
14
14
 
15
15
  // CDNs
16
- import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@2.0.4';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@2.0.6';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@2.0.4/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@2.0.6/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@2.0.4';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@2.0.6';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
package/dist/index.cjs CHANGED
@@ -365,12 +365,24 @@ var RovingTabIndex = class {
365
365
  #initialize() {
366
366
  this.#update(document.activeElement);
367
367
  this.#controller = new AbortController();
368
+ const { signal } = this.#controller;
369
+ document.addEventListener("focusin", this.#onFocusIn, {
370
+ capture: true,
371
+ signal
372
+ });
368
373
  document.addEventListener("keydown", this.#onKeyDown, {
369
374
  capture: true,
370
- signal: this.#controller.signal
375
+ signal
371
376
  });
372
377
  this.#container.setAttribute("data-roving-tabindex-initialized", "");
373
378
  }
379
+ #onFocusIn = (event) => {
380
+ const { target } = event;
381
+ if (!(target instanceof Element) || !this.#focusables.has(target)) {
382
+ return;
383
+ }
384
+ this.#update(target);
385
+ };
374
386
  #onKeyDown = (event) => {
375
387
  if (!event.composedPath().includes(this.#container)) {
376
388
  return;
@@ -435,7 +447,6 @@ var RovingTabIndex = class {
435
447
  if (!focusable) {
436
448
  return;
437
449
  }
438
- this.#update(focusable);
439
450
  focusElement(focusable);
440
451
  };
441
452
  #update(active) {
@@ -503,7 +514,8 @@ var RovingTabIndex = class {
503
514
  return getFocusables(this.#container, {
504
515
  composed: true,
505
516
  filter: this.#selectorFilter,
506
- skipNegativeTabIndexCheck: !this.#options.navigationOnly
517
+ skipNegativeTabIndexCheck: !this.#options.navigationOnly,
518
+ skipVisibilityCheck: true
507
519
  });
508
520
  }
509
521
  };
@@ -522,7 +534,7 @@ function getActiveElement() {
522
534
  * Lightweight roving tabindex utility with fully focus management.
523
535
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
524
536
  *
525
- * @version 2.0.4
537
+ * @version 2.0.6
526
538
  * @author Yusuke Kamiyamane
527
539
  * @license MIT
528
540
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight roving tabindex utility with fully focus management.
4
4
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
5
5
  *
6
- * @version 2.0.4
6
+ * @version 2.0.6
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight roving tabindex utility with fully focus management.
4
4
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
5
5
  *
6
- * @version 2.0.4
6
+ * @version 2.0.6
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -363,12 +363,24 @@ var RovingTabIndex = class {
363
363
  #initialize() {
364
364
  this.#update(document.activeElement);
365
365
  this.#controller = new AbortController();
366
+ const { signal } = this.#controller;
367
+ document.addEventListener("focusin", this.#onFocusIn, {
368
+ capture: true,
369
+ signal
370
+ });
366
371
  document.addEventListener("keydown", this.#onKeyDown, {
367
372
  capture: true,
368
- signal: this.#controller.signal
373
+ signal
369
374
  });
370
375
  this.#container.setAttribute("data-roving-tabindex-initialized", "");
371
376
  }
377
+ #onFocusIn = (event) => {
378
+ const { target } = event;
379
+ if (!(target instanceof Element) || !this.#focusables.has(target)) {
380
+ return;
381
+ }
382
+ this.#update(target);
383
+ };
372
384
  #onKeyDown = (event) => {
373
385
  if (!event.composedPath().includes(this.#container)) {
374
386
  return;
@@ -433,7 +445,6 @@ var RovingTabIndex = class {
433
445
  if (!focusable) {
434
446
  return;
435
447
  }
436
- this.#update(focusable);
437
448
  focusElement(focusable);
438
449
  };
439
450
  #update(active) {
@@ -501,7 +512,8 @@ var RovingTabIndex = class {
501
512
  return getFocusables(this.#container, {
502
513
  composed: true,
503
514
  filter: this.#selectorFilter,
504
- skipNegativeTabIndexCheck: !this.#options.navigationOnly
515
+ skipNegativeTabIndexCheck: !this.#options.navigationOnly,
516
+ skipVisibilityCheck: true
505
517
  });
506
518
  }
507
519
  };
@@ -520,7 +532,7 @@ function getActiveElement() {
520
532
  * Lightweight roving tabindex utility with fully focus management.
521
533
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
522
534
  *
523
- * @version 2.0.4
535
+ * @version 2.0.6
524
536
  * @author Yusuke Kamiyamane
525
537
  * @license MIT
526
538
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/roving-tabindex",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",