@primer/react 38.22.0-rc.984eec337 → 38.22.0-rc.e78d46560

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/CHANGELOG.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  - [#7511](https://github.com/primer/react/pull/7511) [`eb73dee`](https://github.com/primer/react/commit/eb73deea0c9f8fb0fdb44b28445eebc748a39443) Thanks [@RSoeborg](https://github.com/RSoeborg)! - Fix NavList parent item flicker during static-to-interactive transitions when navigating between current sub-items in a SubNav.
12
12
 
13
+ - [#7619](https://github.com/primer/react/pull/7619) [`68aaf61`](https://github.com/primer/react/commit/68aaf617ebbeeb36aa5a7eb4b696d0061f6c2674) Thanks [@hectahertz](https://github.com/hectahertz)! - Memoize ActionMenu context values to prevent unnecessary re-renders of menu items
14
+
13
15
  - [#7708](https://github.com/primer/react/pull/7708) [`d0fa0ff`](https://github.com/primer/react/commit/d0fa0ff2301b3db7a4b66e7aabf3ff544ffb4ef2) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(css): audit :has() selectors and add stylelint guard for Safari
14
16
 
15
17
  - [#7780](https://github.com/primer/react/pull/7780) [`8330aad`](https://github.com/primer/react/commit/8330aadeba6231bf916a9c93757f89018838ebb4) Thanks [@francinelucca](https://github.com/francinelucca)! - fix: Checkbox indeterminate state now persists on click if the state didn't change
@@ -1 +1 @@
1
- {"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/ActionMenu/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8D,MAAM,OAAO,CAAA;AAGlF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAI5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AAIrD,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,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IAE7D;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACpC,GAAG,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAA;AA8I3C,MAAM,MAAM,qBAAqB,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AA2DxH,6CAA6C;AAC7C,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAA;AAe/C,KAAK,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,GAC3C,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,mBAAmB,CAAC,GAAG;IAC/E;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,gBAAgB,CAAC,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAC,KAAK,IAAI,CAAA;CACpE,CAAA;AA8GH,eAAO,MAAM,UAAU;;;kBA3LP,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC;aAC5B,MAAM;;;;CA0L4E,CAAA"}
@@ -1,4 +1,4 @@
1
- import React, { useContext, useState, useEffect, useCallback, useMemo } from 'react';
1
+ import React, { useContext, useMemo, useState, useEffect, useCallback } from 'react';
2
2
  import { clsx } from 'clsx';
3
3
  import { ChevronRightIcon, TriangleDownIcon } from '@primer/octicons-react';
4
4
  import { Divider } from '../ActionList/Divider.js';
@@ -136,17 +136,18 @@ const Menu = ({
136
136
  return child;
137
137
  }
138
138
  });
139
+ const isSubmenu = parentMenuContext.isSubmenu !== undefined;
140
+ const menuContextValue = useMemo(() => ({
141
+ anchorRef,
142
+ renderAnchor,
143
+ anchorId,
144
+ open: combinedOpenState,
145
+ onOpen,
146
+ onClose,
147
+ isSubmenu
148
+ }), [anchorRef, renderAnchor, anchorId, combinedOpenState, onOpen, onClose, isSubmenu]);
139
149
  return /*#__PURE__*/jsx(MenuContext.Provider, {
140
- value: {
141
- anchorRef,
142
- renderAnchor,
143
- anchorId,
144
- open: combinedOpenState,
145
- onOpen,
146
- onClose,
147
- // will be undefined for the outermost level, then false for the top menu, then true inside that
148
- isSubmenu: parentMenuContext.isSubmenu !== undefined
149
- },
150
+ value: menuContextValue,
150
151
  children: contents
151
152
  });
152
153
  };
@@ -263,6 +264,15 @@ const Overlay = ({
263
264
  }
264
265
  }
265
266
  }, [anchorRef]);
267
+ const afterSelect = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose('item-select'), [onClose]);
268
+ const overlayContextValue = useMemo(() => ({
269
+ container: 'ActionMenu',
270
+ listRole: 'menu',
271
+ listLabelledBy: ariaLabelledby || anchorAriaLabelledby || anchorId,
272
+ selectionAttribute: 'aria-checked',
273
+ afterSelect,
274
+ enableFocusZone: isNarrowFullscreen
275
+ }), [ariaLabelledby, anchorAriaLabelledby, anchorId, afterSelect, isNarrowFullscreen]);
266
276
  const isInsideDialog = useContext(DialogContext) !== undefined;
267
277
  return /*#__PURE__*/jsx(AnchoredOverlay, {
268
278
  anchorRef: anchorRef,
@@ -293,16 +303,7 @@ const Overlay = ({
293
303
  [`data-max-height-${overlayProps.maxHeight}`]: ''
294
304
  } : {}),
295
305
  children: /*#__PURE__*/jsx(ActionListContainerContext.Provider, {
296
- value: {
297
- container: 'ActionMenu',
298
- listRole: 'menu',
299
- // If there is a custom aria-labelledby, use that. Otherwise, if exists, use the id that labels the anchor such as tooltip. If none of them exist, use anchor id.
300
- listLabelledBy: ariaLabelledby || anchorAriaLabelledby || anchorId,
301
- selectionAttribute: 'aria-checked',
302
- // Should this be here?
303
- afterSelect: () => onClose === null || onClose === void 0 ? void 0 : onClose('item-select'),
304
- enableFocusZone: isNarrowFullscreen // AnchoredOverlay takes care of focus zone. We only want to enable this if menu is narrow fullscreen.
305
- },
306
+ value: overlayContextValue,
306
307
  children: children
307
308
  })
308
309
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.22.0-rc.984eec337",
4
+ "version": "38.22.0-rc.e78d46560",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",