@y14e/roving-tabindex 2.0.4 → 2.0.5

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.5';
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.5';
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.5/+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.5';
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) {
@@ -522,7 +533,7 @@ function getActiveElement() {
522
533
  * Lightweight roving tabindex utility with fully focus management.
523
534
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
524
535
  *
525
- * @version 2.0.4
536
+ * @version 2.0.5
526
537
  * @author Yusuke Kamiyamane
527
538
  * @license MIT
528
539
  * @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.5
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.5
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) {
@@ -520,7 +531,7 @@ function getActiveElement() {
520
531
  * Lightweight roving tabindex utility with fully focus management.
521
532
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
522
533
  *
523
- * @version 2.0.4
534
+ * @version 2.0.5
524
535
  * @author Yusuke Kamiyamane
525
536
  * @license MIT
526
537
  * @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.5",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",