@lumx/react 3.6.7-alpha.5 → 3.6.7-alpha.7
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/index.js
CHANGED
|
@@ -2668,8 +2668,7 @@ const DISABLED_SELECTOR = `[hidden], [tabindex="-1"], [disabled]:not([disabled="
|
|
|
2668
2668
|
|
|
2669
2669
|
const isNotDisabled = element => !element.matches(DISABLED_SELECTOR);
|
|
2670
2670
|
function getFocusableElements(element) {
|
|
2671
|
-
|
|
2672
|
-
return focusableElements;
|
|
2671
|
+
return Array.from(element.querySelectorAll(TABBABLE_ELEMENTS_SELECTOR)).filter(isNotDisabled);
|
|
2673
2672
|
}
|
|
2674
2673
|
|
|
2675
2674
|
/**
|
|
@@ -2713,6 +2712,7 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2713
2712
|
if (!rootElement || !focusZoneElement) {
|
|
2714
2713
|
return undefined;
|
|
2715
2714
|
}
|
|
2715
|
+
const focusZoneElementOrShadowRoot = focusZoneElement.shadowRoot || focusZoneElement;
|
|
2716
2716
|
|
|
2717
2717
|
// Trap 'Tab' key down focus switch into the focus zone.
|
|
2718
2718
|
const trapTabFocusInFocusZone = evt => {
|
|
@@ -2722,7 +2722,7 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2722
2722
|
if (key !== 'Tab') {
|
|
2723
2723
|
return;
|
|
2724
2724
|
}
|
|
2725
|
-
const focusable = getFirstAndLastFocusable(
|
|
2725
|
+
const focusable = getFirstAndLastFocusable(focusZoneElementOrShadowRoot);
|
|
2726
2726
|
|
|
2727
2727
|
// Prevent focus switch if no focusable available.
|
|
2728
2728
|
if (!focusable.first) {
|
|
@@ -2730,14 +2730,18 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2730
2730
|
return;
|
|
2731
2731
|
}
|
|
2732
2732
|
const activeElement = focusZoneElement.shadowRoot ? focusZoneElement.shadowRoot.activeElement : document.activeElement;
|
|
2733
|
-
console.log('
|
|
2733
|
+
console.log('data', {
|
|
2734
|
+
activeElement,
|
|
2735
|
+
focusable,
|
|
2736
|
+
focusZoneElementOrShadowRoot
|
|
2737
|
+
});
|
|
2734
2738
|
if (
|
|
2735
2739
|
// No previous focus
|
|
2736
2740
|
!activeElement ||
|
|
2737
2741
|
// Previous focus is at the end of the focus zone.
|
|
2738
2742
|
!evt.shiftKey && activeElement === focusable.last ||
|
|
2739
2743
|
// Previous focus is outside the focus zone
|
|
2740
|
-
!
|
|
2744
|
+
!focusZoneElementOrShadowRoot.contains(activeElement)) {
|
|
2741
2745
|
focusable.first.focus();
|
|
2742
2746
|
evt.preventDefault();
|
|
2743
2747
|
return;
|
|
@@ -2757,7 +2761,7 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2757
2761
|
};
|
|
2758
2762
|
|
|
2759
2763
|
// SETUP:
|
|
2760
|
-
if (focusElement &&
|
|
2764
|
+
if (focusElement && focusZoneElementOrShadowRoot.contains(focusElement)) {
|
|
2761
2765
|
// Focus the given element.
|
|
2762
2766
|
focusElement.focus({
|
|
2763
2767
|
preventScroll: true
|
|
@@ -2765,7 +2769,7 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2765
2769
|
} else {
|
|
2766
2770
|
var _getFirstAndLastFocus;
|
|
2767
2771
|
// Focus the first focusable element in the zone.
|
|
2768
|
-
(_getFirstAndLastFocus = getFirstAndLastFocusable(
|
|
2772
|
+
(_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElementOrShadowRoot).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus({
|
|
2769
2773
|
preventScroll: true
|
|
2770
2774
|
});
|
|
2771
2775
|
}
|