@sproutsocial/seeds-react-menu 1.7.6 → 1.7.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.
@@ -8,22 +8,22 @@ $ tsup --dts
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 89.95 KB
12
- CJS dist/v2/index.js 70.74 KB
13
- CJS dist/index.js.map 175.36 KB
14
- CJS dist/v2/index.js.map 146.40 KB
15
- CJS ⚡️ Build success in 342ms
16
- ESM dist/esm/index.js 70.92 KB
17
11
  ESM dist/esm/v2/index.js 60.19 KB
12
+ ESM dist/esm/index.js 71.37 KB
18
13
  ESM dist/esm/chunk-ROQATIB7.js 9.15 KB
19
- ESM dist/esm/index.js.map 151.40 KB
20
14
  ESM dist/esm/v2/index.js.map 126.72 KB
15
+ ESM dist/esm/index.js.map 152.31 KB
21
16
  ESM dist/esm/chunk-ROQATIB7.js.map 22.93 KB
22
- ESM ⚡️ Build success in 343ms
17
+ ESM ⚡️ Build success in 402ms
18
+ CJS dist/index.js 90.48 KB
19
+ CJS dist/v2/index.js 70.74 KB
20
+ CJS dist/index.js.map 176.30 KB
21
+ CJS dist/v2/index.js.map 146.40 KB
22
+ CJS ⚡️ Build success in 403ms
23
23
  DTS Build start
24
- DTS ⚡️ Build success in 15593ms
24
+ DTS ⚡️ Build success in 16150ms
25
25
  DTS dist/index.d.ts 39.04 KB
26
26
  DTS dist/v2/index.d.ts 4.87 KB
27
27
  DTS dist/index.d.mts 39.04 KB
28
28
  DTS dist/v2/index.d.mts 4.87 KB
29
- Done in 16.98s.
29
+ Done in 17.57s.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @sproutsocial/seeds-react-menu
2
2
 
3
+ ## 1.7.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 564ce83: Fix NestedMenu focus management to return focus to toggle button when menu closes (DS-3901)
8
+
9
+ **Changes:**
10
+
11
+ - Added `toggleElementRef` to NestedMenu component to track toggle button element
12
+ - Merged refs in NestedMenuPopout using `mergeRefs()` utility to combine Popout's ref with internal ref
13
+ - Added explicit focus management in `onClose` callback to ensure focus returns to toggle button
14
+ - Added focus management tests to verify behavior
15
+ - Added Storybook story "Focus Management (DS-3901)" to demonstrate the fix
16
+
17
+ **Impact:**
18
+ Users navigating by keyboard will now properly have focus returned to the toggle button when NestedMenu closes via Escape key, clicking menu items, or navigating through nested menus. This improves accessibility and keyboard navigation UX.
19
+
3
20
  ## 1.7.6
4
21
 
5
22
  ### Patch Changes
package/dist/esm/index.js CHANGED
@@ -2207,8 +2207,10 @@ var NestedMenuRoot = ({
2207
2207
  };
2208
2208
 
2209
2209
  // src/NestedMenu/NestedMenuPopout.tsx
2210
+ import "react";
2210
2211
  import { motion as motion2 } from "motion/react";
2211
2212
  import styled9 from "styled-components";
2213
+ import { mergeRefs as mergeRefs4 } from "@sproutsocial/seeds-react-utilities";
2212
2214
  import { jsx as jsx30 } from "react/jsx-runtime";
2213
2215
  var StyledDiv = styled9(motion2.div)`
2214
2216
  overflow: hidden;
@@ -2218,6 +2220,8 @@ var NestedMenuPopout = ({
2218
2220
  menuToggleElement,
2219
2221
  width,
2220
2222
  onClose,
2223
+ toggleElementRef,
2224
+ focusLockProps,
2221
2225
  ...popoutProps
2222
2226
  }) => {
2223
2227
  const { activeMenuContext, rootMenuContextProps, resetSelectedMenuPath } = useNestedMenuContext();
@@ -2227,13 +2231,20 @@ var NestedMenuPopout = ({
2227
2231
  lockPlacement: true,
2228
2232
  onClose: () => {
2229
2233
  onClose?.();
2230
- setTimeout(() => resetSelectedMenuPath?.(), 100);
2234
+ setTimeout(() => {
2235
+ toggleElementRef.current?.focus();
2236
+ resetSelectedMenuPath?.();
2237
+ }, 200);
2231
2238
  },
2232
2239
  isOpen: !!rootMenuContextProps.isOpen,
2233
2240
  openMenu: rootMenuContextProps.openMenu,
2234
2241
  closeMenu: rootMenuContextProps.closeMenu,
2235
2242
  width,
2236
2243
  content: (props) => /* @__PURE__ */ jsx30(StyledDiv, { layout: "position", children: typeof content === "function" ? content(props) : content }),
2244
+ focusLockProps: {
2245
+ crossFrame: false,
2246
+ ...focusLockProps
2247
+ },
2237
2248
  ...popoutProps,
2238
2249
  children: (toggleProps) => /* @__PURE__ */ jsx30(
2239
2250
  MenuToggleProvider,
@@ -2241,7 +2252,11 @@ var NestedMenuPopout = ({
2241
2252
  menuContext: {
2242
2253
  ...activeMenuContext,
2243
2254
  ...rootMenuContextProps,
2244
- ...toggleProps
2255
+ ...toggleProps,
2256
+ ref: mergeRefs4(
2257
+ toggleProps.ref,
2258
+ toggleElementRef
2259
+ )
2245
2260
  },
2246
2261
  children: menuToggleElement
2247
2262
  }
@@ -2319,6 +2334,7 @@ var NestedMenu = ({
2319
2334
  const [currentMenuId, setCurrentMenuId] = useState(initialMenuId);
2320
2335
  const [isAdding, setIsAdding] = useState(false);
2321
2336
  const popoutUpdateRef = useRef2();
2337
+ const toggleElementRef = useRef2(null);
2322
2338
  const setSelectedMenuId = (id) => {
2323
2339
  setIsAdding(true);
2324
2340
  setSelectedMenuPath((currentPath) => [...currentPath, id]);
@@ -2483,6 +2499,7 @@ var NestedMenu = ({
2483
2499
  ) }),
2484
2500
  menuToggleElement,
2485
2501
  width,
2502
+ toggleElementRef,
2486
2503
  scheduleUpdateRef: (callback) => {
2487
2504
  popoutUpdateRef.current = callback;
2488
2505
  externalPopoutUpdateRef?.(callback);