@lumx/react 3.6.7-alpha.1 → 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 +1 -1
- package/index.js +5 -5
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/popover/Popover.tsx +4 -4
- package/src/utils/focus/getFocusableElements.ts +3 -1
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^3.6.7-alpha.
|
|
11
|
-
"@lumx/icons": "^3.6.7-alpha.
|
|
10
|
+
"@lumx/core": "^3.6.7-alpha.2",
|
|
11
|
+
"@lumx/icons": "^3.6.7-alpha.2",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.3.2",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"build:storybook": "storybook build"
|
|
113
113
|
},
|
|
114
114
|
"sideEffects": false,
|
|
115
|
-
"version": "3.6.7-alpha.
|
|
115
|
+
"version": "3.6.7-alpha.2"
|
|
116
116
|
}
|
|
@@ -61,7 +61,7 @@ export interface PopoverProps extends GenericProps, HasTheme {
|
|
|
61
61
|
/** Whether the popover should be rendered into a DOM node that exists outside the DOM hierarchy of the parent component. */
|
|
62
62
|
usePortal?: boolean;
|
|
63
63
|
/** The element in which the focus trap should be set. Default to popover. */
|
|
64
|
-
|
|
64
|
+
focusTrapZoneElement?: RefObject<HTMLElement>;
|
|
65
65
|
/** Z-axis position. */
|
|
66
66
|
zIndex?: number;
|
|
67
67
|
/** On close callback (on click away or Escape pressed). */
|
|
@@ -117,7 +117,7 @@ const _InnerPopover: Comp<PopoverProps, HTMLDivElement> = forwardRef((props, ref
|
|
|
117
117
|
boundaryRef,
|
|
118
118
|
fitToAnchorWidth,
|
|
119
119
|
fitWithinViewportHeight,
|
|
120
|
-
|
|
120
|
+
focusTrapZoneElement,
|
|
121
121
|
offset,
|
|
122
122
|
placement,
|
|
123
123
|
style,
|
|
@@ -149,8 +149,8 @@ const _InnerPopover: Comp<PopoverProps, HTMLDivElement> = forwardRef((props, ref
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
const unmountSentinel = useRestoreFocusOnClose({ focusAnchorOnClose, anchorRef, parentElement }, popperElement);
|
|
152
|
-
const focusZoneElement =
|
|
153
|
-
|
|
152
|
+
const focusZoneElement = focusTrapZoneElement?.current || popoverRef?.current;
|
|
153
|
+
|
|
154
154
|
useCallbackOnEscape(onClose, isOpen && closeOnEscape);
|
|
155
155
|
|
|
156
156
|
/** Only set focus within if the focus trap is disabled as they interfere with one another. */
|
|
@@ -3,5 +3,7 @@ import { DISABLED_SELECTOR, TABBABLE_ELEMENTS_SELECTOR } from './constants';
|
|
|
3
3
|
const isNotDisabled = (element: HTMLElement) => !element.matches(DISABLED_SELECTOR);
|
|
4
4
|
|
|
5
5
|
export function getFocusableElements(element: HTMLElement): HTMLElement[] {
|
|
6
|
-
|
|
6
|
+
const focusableElements = element.shadowRoot ? getFocusableElements(element.shadowRoot) : Array.from(element.querySelectorAll<HTMLElement>(TABBABLE_ELEMENTS_SELECTOR)).filter(isNotDisabled);
|
|
7
|
+
|
|
8
|
+
return focusableElements;
|
|
7
9
|
}
|