@lumx/react 3.6.7-alpha.0 → 3.6.7-alpha.2
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.d.ts +2 -2
- package/index.js +6 -4
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/popover/Popover.tsx +5 -4
- package/src/utils/focus/getFocusableElements.ts +3 -1
package/index.d.ts
CHANGED
|
@@ -794,8 +794,8 @@ interface PopoverProps extends GenericProps, HasTheme {
|
|
|
794
794
|
placement?: Placement;
|
|
795
795
|
/** Whether the popover should be rendered into a DOM node that exists outside the DOM hierarchy of the parent component. */
|
|
796
796
|
usePortal?: boolean;
|
|
797
|
-
/** The element in which the focus trap should be set. Default to popover */
|
|
798
|
-
|
|
797
|
+
/** The element in which the focus trap should be set. Default to popover. */
|
|
798
|
+
focusTrapZoneElement?: RefObject<HTMLElement>;
|
|
799
799
|
/** Z-axis position. */
|
|
800
800
|
zIndex?: number;
|
|
801
801
|
/** On close callback (on click away or Escape pressed). */
|
package/index.js
CHANGED
|
@@ -2668,7 +2668,8 @@ 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
|
-
|
|
2671
|
+
const focusableElements = element.shadowRoot ? getFocusableElements(element.shadowRoot) : Array.from(element.querySelectorAll(TABBABLE_ELEMENTS_SELECTOR)).filter(isNotDisabled);
|
|
2672
|
+
return focusableElements;
|
|
2672
2673
|
}
|
|
2673
2674
|
|
|
2674
2675
|
/**
|
|
@@ -6538,7 +6539,7 @@ function usePopoverStyle(_ref5) {
|
|
|
6538
6539
|
};
|
|
6539
6540
|
}
|
|
6540
6541
|
|
|
6541
|
-
const _excluded$m = ["anchorRef", "as", "children", "className", "closeOnClickAway", "closeOnEscape", "elevation", "focusElement", "hasArrow", "isOpen", "onClose", "parentElement", "usePortal", "focusAnchorOnClose", "withFocusTrap", "boundaryRef", "fitToAnchorWidth", "fitWithinViewportHeight", "
|
|
6542
|
+
const _excluded$m = ["anchorRef", "as", "children", "className", "closeOnClickAway", "closeOnEscape", "elevation", "focusElement", "hasArrow", "isOpen", "onClose", "parentElement", "usePortal", "focusAnchorOnClose", "withFocusTrap", "boundaryRef", "fitToAnchorWidth", "fitWithinViewportHeight", "focusTrapZoneElement", "offset", "placement", "style", "theme", "zIndex"];
|
|
6542
6543
|
|
|
6543
6544
|
/**
|
|
6544
6545
|
* Defines the props of the component.
|
|
@@ -6591,7 +6592,7 @@ const _InnerPopover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
6591
6592
|
boundaryRef,
|
|
6592
6593
|
fitToAnchorWidth,
|
|
6593
6594
|
fitWithinViewportHeight,
|
|
6594
|
-
|
|
6595
|
+
focusTrapZoneElement,
|
|
6595
6596
|
offset,
|
|
6596
6597
|
placement,
|
|
6597
6598
|
style,
|
|
@@ -6625,11 +6626,12 @@ const _InnerPopover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
6625
6626
|
anchorRef,
|
|
6626
6627
|
parentElement
|
|
6627
6628
|
}, popperElement);
|
|
6629
|
+
const focusZoneElement = (focusTrapZoneElement === null || focusTrapZoneElement === void 0 ? void 0 : focusTrapZoneElement.current) || (popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current);
|
|
6628
6630
|
useCallbackOnEscape(onClose, isOpen && closeOnEscape);
|
|
6629
6631
|
|
|
6630
6632
|
/** Only set focus within if the focus trap is disabled as they interfere with one another. */
|
|
6631
6633
|
useFocus(focusElement === null || focusElement === void 0 ? void 0 : focusElement.current, !withFocusTrap && isOpen && isPositioned);
|
|
6632
|
-
useFocusTrap(withFocusTrap && isOpen &&
|
|
6634
|
+
useFocusTrap(withFocusTrap && isOpen && focusZoneElement, focusElement === null || focusElement === void 0 ? void 0 : focusElement.current);
|
|
6633
6635
|
const clickAwayRefs = useRef([popoverRef, anchorRef]);
|
|
6634
6636
|
const mergedRefs = useMergeRefs(setPopperElement, ref, popoverRef);
|
|
6635
6637
|
return isOpen ? renderPopover( /*#__PURE__*/React.createElement(Component, _extends({}, forwardedProps, {
|