react-magma-dom 4.12.1-next.4 → 4.12.1-next.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/dist/esm/index.js +12 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/react-magma-dom.cjs.development.js +12 -32
- package/dist/react-magma-dom.cjs.development.js.map +1 -1
- package/dist/react-magma-dom.cjs.production.min.js +1 -1
- package/dist/react-magma-dom.cjs.production.min.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -11238,7 +11238,7 @@ function useFocusLock(active, header, body) {
|
|
|
11238
11238
|
var _rootNode$current;
|
|
11239
11239
|
focusableItems.current = Array.from(((_rootNode$current = rootNode.current) == null ? void 0 : _rootNode$current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"]), video')) || []).filter(function (element) {
|
|
11240
11240
|
var style = window.getComputedStyle(element);
|
|
11241
|
-
return element instanceof HTMLElement && style.display !== 'none' && style.visibility !== 'hidden' && !element.hasAttribute('disabled')
|
|
11241
|
+
return element instanceof HTMLElement && style.display !== 'none' && style.visibility !== 'hidden' && !element.hasAttribute('disabled');
|
|
11242
11242
|
});
|
|
11243
11243
|
};
|
|
11244
11244
|
useEffect(function () {
|
|
@@ -11277,13 +11277,7 @@ function useFocusLock(active, header, body) {
|
|
|
11277
11277
|
firstItem = _focusableItems$curre[0],
|
|
11278
11278
|
lastItem = _focusableItems$curre[length - 1];
|
|
11279
11279
|
if (active && key === 'Tab') {
|
|
11280
|
-
//
|
|
11281
|
-
// This prevents nested modals from interfering with each other.
|
|
11282
|
-
var activeEl = document.activeElement;
|
|
11283
|
-
if (rootNode.current && !rootNode.current.contains(activeEl) && activeEl !== (header == null ? void 0 : header.current)) {
|
|
11284
|
-
return;
|
|
11285
|
-
}
|
|
11286
|
-
// If no focusable items, prevent tabbing entirely
|
|
11280
|
+
// If no focusable items are
|
|
11287
11281
|
if (length === 0) {
|
|
11288
11282
|
event.preventDefault();
|
|
11289
11283
|
return;
|
|
@@ -11291,36 +11285,22 @@ function useFocusLock(active, header, body) {
|
|
|
11291
11285
|
// If only one item then prevent tabbing when locked
|
|
11292
11286
|
if (length === 1) {
|
|
11293
11287
|
event.preventDefault();
|
|
11294
|
-
if (firstItem !==
|
|
11288
|
+
if (firstItem !== document.activeElement) {
|
|
11295
11289
|
firstItem.focus();
|
|
11296
11290
|
}
|
|
11297
11291
|
return;
|
|
11298
11292
|
}
|
|
11299
|
-
//
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
if (currentIndex === -1) {
|
|
11304
|
-
// Focus is on an untracked element (e.g. the header)
|
|
11305
|
-
if (shiftKey) {
|
|
11306
|
-
lastItem.focus();
|
|
11307
|
-
} else {
|
|
11308
|
-
firstItem.focus();
|
|
11309
|
-
}
|
|
11293
|
+
// If focused on last item then focus on first item when tab is pressed
|
|
11294
|
+
if (!shiftKey && document.activeElement === lastItem) {
|
|
11295
|
+
event.preventDefault();
|
|
11296
|
+
firstItem.focus();
|
|
11310
11297
|
return;
|
|
11311
11298
|
}
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
}
|
|
11318
|
-
} else {
|
|
11319
|
-
if (currentIndex === length - 1) {
|
|
11320
|
-
firstItem.focus();
|
|
11321
|
-
} else {
|
|
11322
|
-
focusableItems.current[currentIndex + 1].focus();
|
|
11323
|
-
}
|
|
11299
|
+
// If focused on first item then focus on last item when shift + tab is pressed
|
|
11300
|
+
if (shiftKey && (document.activeElement === firstItem || document.activeElement === (header == null ? void 0 : header.current))) {
|
|
11301
|
+
event.preventDefault();
|
|
11302
|
+
lastItem.focus();
|
|
11303
|
+
return;
|
|
11324
11304
|
}
|
|
11325
11305
|
}
|
|
11326
11306
|
};
|