@sproutsocial/seeds-react-menu 1.18.3 → 1.18.4
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +21 -0
- package/dist/esm/index.js +41 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/NestedMenu/NestedMenuPopout.tsx +57 -4
- package/src/v3/ModalStories.stories.tsx +5 -125
- package/src/v3/MultiCombobox.stories.tsx +5 -9
package/dist/index.js
CHANGED
|
@@ -2650,6 +2650,9 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
|
2650
2650
|
var StyledDiv = (0, import_styled_components12.default)(import_react30.motion.div)`
|
|
2651
2651
|
overflow: hidden;
|
|
2652
2652
|
`;
|
|
2653
|
+
var RETURN_FOCUS_DELAY = 200;
|
|
2654
|
+
var RETURN_FOCUS_RETRY_DELAY = 50;
|
|
2655
|
+
var RETURN_FOCUS_BUDGET = 1e3;
|
|
2653
2656
|
var NestedMenuPopout = ({
|
|
2654
2657
|
content,
|
|
2655
2658
|
menuToggleElement,
|
|
@@ -2660,16 +2663,43 @@ var NestedMenuPopout = ({
|
|
|
2660
2663
|
...popoutProps
|
|
2661
2664
|
}) => {
|
|
2662
2665
|
const { activeMenuContext, rootMenuContextProps, resetSelectedMenuPath } = useNestedMenuContext();
|
|
2666
|
+
const closeTimerRef = (0, import_react29.useRef)();
|
|
2667
|
+
const retryTimerRef = (0, import_react29.useRef)();
|
|
2668
|
+
(0, import_react29.useEffect)(
|
|
2669
|
+
() => () => {
|
|
2670
|
+
clearTimeout(closeTimerRef.current);
|
|
2671
|
+
clearTimeout(retryTimerRef.current);
|
|
2672
|
+
},
|
|
2673
|
+
[]
|
|
2674
|
+
);
|
|
2675
|
+
const attemptReturnFocus = (deadline) => {
|
|
2676
|
+
const toggleElement = toggleElementRef.current;
|
|
2677
|
+
if (toggleElement) {
|
|
2678
|
+
if (document.activeElement === toggleElement) {
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
toggleElement.focus();
|
|
2682
|
+
if (document.activeElement === toggleElement) {
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
if (Date.now() < deadline) {
|
|
2687
|
+
retryTimerRef.current = setTimeout(
|
|
2688
|
+
() => attemptReturnFocus(deadline),
|
|
2689
|
+
RETURN_FOCUS_RETRY_DELAY
|
|
2690
|
+
);
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2663
2693
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2664
2694
|
MenuPopout,
|
|
2665
2695
|
{
|
|
2666
2696
|
lockPlacement: true,
|
|
2667
2697
|
onClose: () => {
|
|
2668
2698
|
onClose?.();
|
|
2669
|
-
setTimeout(() => {
|
|
2670
|
-
|
|
2699
|
+
closeTimerRef.current = setTimeout(() => {
|
|
2700
|
+
attemptReturnFocus(Date.now() + RETURN_FOCUS_BUDGET);
|
|
2671
2701
|
resetSelectedMenuPath?.();
|
|
2672
|
-
},
|
|
2702
|
+
}, RETURN_FOCUS_DELAY);
|
|
2673
2703
|
},
|
|
2674
2704
|
isOpen: !!rootMenuContextProps.isOpen,
|
|
2675
2705
|
openMenu: rootMenuContextProps.openMenu,
|