@vaadin/a11y-base 25.0.4 → 25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/a11y-base",
3
- "version": "25.0.4",
3
+ "version": "25.0.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,14 +31,14 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
- "@vaadin/component-base": "~25.0.4",
34
+ "@vaadin/component-base": "~25.0.5",
35
35
  "lit": "^3.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@vaadin/chai-plugins": "~25.0.4",
39
- "@vaadin/test-runner-commands": "~25.0.4",
38
+ "@vaadin/chai-plugins": "~25.0.5",
39
+ "@vaadin/test-runner-commands": "~25.0.5",
40
40
  "@vaadin/testing-helpers": "^2.0.0",
41
41
  "sinon": "^21.0.0"
42
42
  },
43
- "gitHead": "17170982c3efa1d426af4fabb70ea36b70151347"
43
+ "gitHead": "f9de924c232acc7b113e9f7f48368e8ca8105f81"
44
44
  }
@@ -5,6 +5,12 @@
5
5
  */
6
6
  import type { ReactiveController } from 'lit';
7
7
 
8
+ /**
9
+ * Returns the innermost active focus trap node that contains the given element,
10
+ * or null if the element is not inside any active focus trap.
11
+ */
12
+ export declare function getActiveTrappingNode(element: HTMLElement): HTMLElement | null;
13
+
8
14
  /**
9
15
  * A controller for trapping focus within a DOM node.
10
16
  */
@@ -7,6 +7,23 @@ import { getFocusableElements, isElementFocused, isKeyboardActive } from './focu
7
7
 
8
8
  const instances = [];
9
9
 
10
+ /**
11
+ * Returns the innermost active focus trap node that contains the given element,
12
+ * or null if the element is not inside any active focus trap.
13
+ *
14
+ * @param {HTMLElement} element
15
+ * @return {HTMLElement | null}
16
+ */
17
+ export function getActiveTrappingNode(element) {
18
+ // Iterate backwards since instances are ordered outer-to-inner (push/pop)
19
+ for (let i = instances.length - 1; i >= 0; i--) {
20
+ if (instances[i].__trapNode?.contains(element)) {
21
+ return instances[i].__trapNode;
22
+ }
23
+ }
24
+ return null;
25
+ }
26
+
10
27
  /**
11
28
  * A controller for trapping focus within a DOM node.
12
29
  */
@@ -123,6 +140,11 @@ export class FocusTrapController {
123
140
  }
124
141
 
125
142
  if (event.key === 'Tab') {
143
+ // Skip if another handler already processed this event
144
+ if (event.defaultPrevented) {
145
+ return;
146
+ }
147
+
126
148
  event.preventDefault();
127
149
 
128
150
  const backward = event.shiftKey;