@primer/behaviors 0.0.0-20251215034054 → 0.0.0-20251215034201
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/dist/cjs/focus-trap.js +11 -7
- package/dist/esm/focus-trap.mjs +11 -7
- package/package.json +1 -1
package/dist/cjs/focus-trap.js
CHANGED
|
@@ -7,7 +7,7 @@ eventListenerSignal.polyfill();
|
|
|
7
7
|
const suspendedTrapStack = [];
|
|
8
8
|
let activeTrap = undefined;
|
|
9
9
|
const SR_ONLY_STYLES = 'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0';
|
|
10
|
-
function createSentinel(onFocus) {
|
|
10
|
+
function createSentinel({ onFocus }) {
|
|
11
11
|
const sentinel = document.createElement('span');
|
|
12
12
|
sentinel.setAttribute('class', 'sentinel');
|
|
13
13
|
sentinel.setAttribute('tabindex', '0');
|
|
@@ -57,13 +57,17 @@ function focusTrap(container, initialFocus, abortSignal) {
|
|
|
57
57
|
const controller = new AbortController();
|
|
58
58
|
const signal = abortSignal !== null && abortSignal !== void 0 ? abortSignal : controller.signal;
|
|
59
59
|
container.setAttribute('data-focus-trap', 'active');
|
|
60
|
-
const sentinelStart = createSentinel(
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const sentinelStart = createSentinel({
|
|
61
|
+
onFocus: () => {
|
|
62
|
+
const lastFocusableChild = iterateFocusableElements.getFocusableChild(container, true);
|
|
63
|
+
lastFocusableChild === null || lastFocusableChild === void 0 ? void 0 : lastFocusableChild.focus();
|
|
64
|
+
},
|
|
63
65
|
});
|
|
64
|
-
const sentinelEnd = createSentinel(
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
const sentinelEnd = createSentinel({
|
|
67
|
+
onFocus: () => {
|
|
68
|
+
const firstFocusableChild = iterateFocusableElements.getFocusableChild(container);
|
|
69
|
+
firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
|
|
70
|
+
},
|
|
67
71
|
});
|
|
68
72
|
const hasExistingSentinels = container.querySelector(':scope > span.sentinel') !== null;
|
|
69
73
|
if (!hasExistingSentinels) {
|
package/dist/esm/focus-trap.mjs
CHANGED
|
@@ -5,7 +5,7 @@ polyfill();
|
|
|
5
5
|
const suspendedTrapStack = [];
|
|
6
6
|
let activeTrap = undefined;
|
|
7
7
|
const SR_ONLY_STYLES = 'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0';
|
|
8
|
-
function createSentinel(onFocus) {
|
|
8
|
+
function createSentinel({ onFocus }) {
|
|
9
9
|
const sentinel = document.createElement('span');
|
|
10
10
|
sentinel.setAttribute('class', 'sentinel');
|
|
11
11
|
sentinel.setAttribute('tabindex', '0');
|
|
@@ -55,13 +55,17 @@ function focusTrap(container, initialFocus, abortSignal) {
|
|
|
55
55
|
const controller = new AbortController();
|
|
56
56
|
const signal = abortSignal !== null && abortSignal !== void 0 ? abortSignal : controller.signal;
|
|
57
57
|
container.setAttribute('data-focus-trap', 'active');
|
|
58
|
-
const sentinelStart = createSentinel(
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const sentinelStart = createSentinel({
|
|
59
|
+
onFocus: () => {
|
|
60
|
+
const lastFocusableChild = getFocusableChild(container, true);
|
|
61
|
+
lastFocusableChild === null || lastFocusableChild === void 0 ? void 0 : lastFocusableChild.focus();
|
|
62
|
+
},
|
|
61
63
|
});
|
|
62
|
-
const sentinelEnd = createSentinel(
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const sentinelEnd = createSentinel({
|
|
65
|
+
onFocus: () => {
|
|
66
|
+
const firstFocusableChild = getFocusableChild(container);
|
|
67
|
+
firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
|
|
68
|
+
},
|
|
65
69
|
});
|
|
66
70
|
const hasExistingSentinels = container.querySelector(':scope > span.sentinel') !== null;
|
|
67
71
|
if (!hasExistingSentinels) {
|