@lumx/react 3.2.0 → 3.2.1-alpha.0
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
|
@@ -2282,11 +2282,15 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2282
2282
|
// SETUP:
|
|
2283
2283
|
if (focusElement && focusZoneElement.contains(focusElement)) {
|
|
2284
2284
|
// Focus the given element.
|
|
2285
|
-
focusElement.focus(
|
|
2285
|
+
focusElement.focus({
|
|
2286
|
+
preventScroll: true
|
|
2287
|
+
});
|
|
2286
2288
|
} else {
|
|
2287
2289
|
var _getFirstAndLastFocus;
|
|
2288
2290
|
// Focus the first focusable element in the zone.
|
|
2289
|
-
(_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElement).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus(
|
|
2291
|
+
(_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElement).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus({
|
|
2292
|
+
preventScroll: true
|
|
2293
|
+
});
|
|
2290
2294
|
}
|
|
2291
2295
|
FOCUS_TRAPS.register(focusTrap);
|
|
2292
2296
|
|
|
@@ -6198,18 +6202,19 @@ const _InnerPopover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
6198
6202
|
* unless specifically requested not to.
|
|
6199
6203
|
*/
|
|
6200
6204
|
if (isFocusedWithin.current && focusAnchorOnClose) {
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
const firstFocusable = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) && getFirstAndLastFocusable(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current).first;
|
|
6205
|
-
if (firstFocusable) {
|
|
6205
|
+
var _elementToFocus;
|
|
6206
|
+
let elementToFocus = parentElement === null || parentElement === void 0 ? void 0 : parentElement.current;
|
|
6207
|
+
if (!elementToFocus && anchorRef !== null && anchorRef !== void 0 && anchorRef.current) {
|
|
6206
6208
|
// Focus the first focusable element in anchor.
|
|
6207
|
-
|
|
6208
|
-
}
|
|
6209
|
-
|
|
6209
|
+
elementToFocus = getFirstAndLastFocusable(anchorRef.current).first;
|
|
6210
|
+
}
|
|
6211
|
+
if (!elementToFocus) {
|
|
6210
6212
|
// Fallback on the anchor element.
|
|
6211
|
-
anchorRef === null || anchorRef === void 0 ? void 0 :
|
|
6213
|
+
elementToFocus = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current;
|
|
6212
6214
|
}
|
|
6215
|
+
(_elementToFocus = elementToFocus) === null || _elementToFocus === void 0 ? void 0 : _elementToFocus.focus({
|
|
6216
|
+
preventScroll: true
|
|
6217
|
+
});
|
|
6213
6218
|
}
|
|
6214
6219
|
onClose();
|
|
6215
6220
|
}, [anchorRef, focusAnchorOnClose, onClose, parentElement]);
|
|
@@ -9291,7 +9296,7 @@ const SelectVariant = {
|
|
|
9291
9296
|
chip: 'chip'
|
|
9292
9297
|
};
|
|
9293
9298
|
|
|
9294
|
-
const _excluded$Y = ["children", "className", "isMultiple", "closeOnClick", "disabled", "error", "hasError", "helper", "id", "isDisabled", "isEmpty", "isOpen", "isRequired", "isValid", "label", "onClear", "onDropdownClose", "onInfiniteScroll", "onInputClick", "placeholder", "theme", "value", "variant"];
|
|
9299
|
+
const _excluded$Y = ["children", "className", "focusElement", "isMultiple", "closeOnClick", "disabled", "error", "hasError", "helper", "id", "isDisabled", "isEmpty", "isOpen", "isRequired", "isValid", "label", "onClear", "onDropdownClose", "onInfiniteScroll", "onInputClick", "placeholder", "theme", "value", "variant"];
|
|
9295
9300
|
|
|
9296
9301
|
/** The display name of the component. */
|
|
9297
9302
|
const COMPONENT_NAME$W = 'Select';
|
|
@@ -9308,6 +9313,7 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9308
9313
|
let {
|
|
9309
9314
|
children,
|
|
9310
9315
|
className,
|
|
9316
|
+
focusElement,
|
|
9311
9317
|
isMultiple,
|
|
9312
9318
|
closeOnClick = !isMultiple,
|
|
9313
9319
|
disabled,
|
|
@@ -9334,6 +9340,7 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9334
9340
|
const selectId = useMemo(() => id || `select-${uid()}`, [id]);
|
|
9335
9341
|
const anchorRef = useRef(null);
|
|
9336
9342
|
const selectRef = useRef(null);
|
|
9343
|
+
const dropdownRef = useRef(null);
|
|
9337
9344
|
const isFocus = useListenFocus(anchorRef);
|
|
9338
9345
|
const handleKeyboardNav = useCallback(evt => {
|
|
9339
9346
|
if ((evt.key === 'Enter' || evt.key === ' ' || evt.key === 'ArrowDown') && onInputClick) {
|
|
@@ -9348,6 +9355,9 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9348
9355
|
}
|
|
9349
9356
|
anchorRef === null || anchorRef === void 0 ? void 0 : (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.blur();
|
|
9350
9357
|
};
|
|
9358
|
+
|
|
9359
|
+
// Handle focus trap.
|
|
9360
|
+
useFocusTrap(isOpen && dropdownRef.current, focusElement === null || focusElement === void 0 ? void 0 : focusElement.current);
|
|
9351
9361
|
return /*#__PURE__*/React.createElement("div", {
|
|
9352
9362
|
ref: mergeRefs(ref, selectRef),
|
|
9353
9363
|
className: classnames(className, handleBasicClasses({
|
|
@@ -9388,7 +9398,8 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9388
9398
|
isOpen: !!isOpen,
|
|
9389
9399
|
placement: Placement.BOTTOM_START,
|
|
9390
9400
|
onClose: onClose,
|
|
9391
|
-
onInfiniteScroll: onInfiniteScroll
|
|
9401
|
+
onInfiniteScroll: onInfiniteScroll,
|
|
9402
|
+
ref: dropdownRef
|
|
9392
9403
|
}, children), hasError && error && /*#__PURE__*/React.createElement(InputHelper, {
|
|
9393
9404
|
className: `${CLASSNAME$T}__helper`,
|
|
9394
9405
|
kind: Kind.error,
|