@primer/react 0.0.0-20260522115117 → 0.0.0-20260522120829

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
@@ -1,28 +1,9 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260522115117
3
+ ## 0.0.0-20260522120829
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - [#7864](https://github.com/primer/react/pull/7864) [`3edf601`](https://github.com/primer/react/commit/3edf60187465206244029c521db76d64a178dc82) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Eliminate nested-update cascades in `useFocus`, `PageLayout.Pane`, and
8
- `AnchoredOverlay`:
9
-
10
- - `useFocus` no longer produces a second re-render after focusing; one
11
- `focus()` call now results in exactly one render instead of two.
12
- - `PageLayout.Pane` (resizable) no longer triggers a forced re-render
13
- before paint on mount. The CSS variable and ARIA attributes are still
14
- updated synchronously in the layout effect; the React state sync is
15
- wrapped in `startTransition` so it runs in the transition lane rather
16
- than as part of the layout-effect commit.
17
- - `AnchoredOverlay` no longer keeps `useAnchoredPosition`'s scroll
18
- listeners and `ResizeObserver` attached while it is closed. After an
19
- open→close cycle, the first scroll/resize event no longer fires a
20
- spurious `setPosition(undefined)` that re-renders the closed overlay.
21
-
22
- Also adds a profiler-based test harness at
23
- `src/utils/testing/profiler.tsx` so future regressions can be pinned with
24
- `counter.updateCount` and `counter.nestedUpdateCount` assertions.
25
-
26
7
  - Fake entry to force publishing
27
8
 
28
9
  ## 38.24.0
@@ -1 +1 @@
1
- {"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../src/AnchoredOverlay/AnchoredOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAmC,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AAChE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KA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CAAC,CAAC,CAAA;AAS9G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAoRnF,CAAA"}
@@ -110,13 +110,10 @@ const AnchoredOverlay = ({
110
110
  anchorOffset,
111
111
  displayInViewport,
112
112
  onPositionChange: positionChange,
113
- // Disable position computation, scroll listeners, and resize observers
114
- // when the overlay is closed (no floating element to position) or when
115
- // native CSS anchor positioning is active (the browser handles it).
116
- // Skipping the listeners while closed avoids a wasted re-render on the
117
- // first scroll/resize after a close (where `setPosition(undefined)`
118
- // would otherwise clear the stale open-position state).
119
- enabled: open && !cssAnchorPositioning
113
+ // When native CSS anchor positioning is active, skip JS-based position
114
+ // computation, scroll listeners, and resize observers since the browser
115
+ // handles repositioning natively.
116
+ enabled: !cssAnchorPositioning
120
117
  }, [overlayElement]);
121
118
  useEffect(() => {
122
119
  // ensure overlay ref gets cleared when closed, so position can reset between closing/re-opening
@@ -1 +1 @@
1
- {"version":3,"file":"usePaneWidth.d.ts","sourceRoot":"","sources":["../../src/PageLayout/usePaneWidth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAA;AAQrD,KAAK,WAAW,GAAG,GAAG,MAAM,IAAI,CAAA;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,WAAW,CAAA;IAChB,OAAO,EAAE,WAAW,CAAA;IACpB,GAAG,EAAE,WAAW,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEpD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,kBAAkB,CAAA;AAE3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,cAAc,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,uFAAuF;IACvF,e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AI,OAAO,cAAc,KAAG,KAAK,IAAI,kBAErE,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,cAAc,KAAG,KAAK,IAAI,SAE5D,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,GAAG,cAAc,KAAG,MAOvD,CAAA;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAGpD;AAID,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,WAAW,GAAG,IAAI,EAC1B,QAAQ;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAC,SASvD,CAAA;AA8BD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,mBAA2B,EAC3B,WAAW,EACX,YAAY,EAAE,eAAe,GAC9B,EAAE,mBAAmB,GAAG,kBAAkB,CAkR1C"}
@@ -350,15 +350,13 @@ function usePaneWidth(t0) {
350
350
  maxWidthDiffRef.current = getMaxWidthDiffFromViewport();
351
351
  const initialMax = getMaxPaneWidthRef.current();
352
352
  maxPaneWidthRef.current = initialMax;
353
+ setMaxPaneWidth(initialMax);
353
354
  (_paneRef$current3 = paneRef.current) === null || _paneRef$current3 === void 0 ? void 0 : _paneRef$current3.style.setProperty("--pane-max-width", `${initialMax}px`);
354
355
  updateAriaValues(handleRef.current, {
355
356
  min: minPaneWidth,
356
357
  max: initialMax,
357
358
  current: currentWidthRef.current
358
359
  });
359
- startTransition(() => {
360
- setMaxPaneWidth(initialMax);
361
- });
362
360
  if (customMaxWidth !== null && !constrainToViewport) {
363
361
  return;
364
362
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAnchoredPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnchoredPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAA;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAcD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,CAAC,EAAE,4BAA4B,EACvC,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC;IACD,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACnD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACjD,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;CACrC,CAiJA"}
@@ -24,6 +24,16 @@ function getScrollableAncestors(element) {
24
24
  scrollables.push(window);
25
25
  return scrollables;
26
26
  }
27
+ function hasOverflowingDescendant(element) {
28
+ if (!element) return false;
29
+ for (const descendant of element.querySelectorAll('*')) {
30
+ if (descendant.scrollHeight > descendant.clientHeight || descendant.scrollWidth > descendant.clientWidth) {
31
+ return true;
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+
27
37
  /**
28
38
  * Calculates the top and left values for an absolutely-positioned floating element
29
39
  * to be anchored to some anchor element. Returns refs for the floating element
@@ -50,9 +60,23 @@ function useAnchoredPosition(settings, dependencies = []) {
50
60
  const updateElementHeight = () => {
51
61
  let heightUpdated = false;
52
62
  setPrevHeight(prevHeight => {
53
- var _floatingElementRef$c, _floatingElementRef$c2;
54
- // if the element is trying to shrink in height, restore to old height to prevent it from jumping
55
- if (prevHeight && prevHeight > ((_floatingElementRef$c = (_floatingElementRef$c2 = floatingElementRef.current) === null || _floatingElementRef$c2 === void 0 ? void 0 : _floatingElementRef$c2.clientHeight) !== null && _floatingElementRef$c !== void 0 ? _floatingElementRef$c : 0)) {
63
+ var _floatingElement$clie, _floatingElement$scro;
64
+ const floatingElement = floatingElementRef.current;
65
+ const currentHeight = (_floatingElement$clie = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.clientHeight) !== null && _floatingElement$clie !== void 0 ? _floatingElement$clie : 0;
66
+ const desiredHeight = Math.max((_floatingElement$scro = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.scrollHeight) !== null && _floatingElement$scro !== void 0 ? _floatingElement$scro : 0, currentHeight);
67
+ const contentNeedsMoreHeight = prevHeight !== undefined && desiredHeight > prevHeight || hasOverflowingDescendant(floatingElement);
68
+
69
+ // if the element is trying to shrink in height, restore to old height to prevent it from jumping.
70
+ // When the content now needs to grow past the previous height, clear any stale inline height instead.
71
+ if (prevHeight && prevHeight > currentHeight) {
72
+ if (contentNeedsMoreHeight) {
73
+ requestAnimationFrame(() => {
74
+ if (floatingElementRef.current instanceof HTMLElement) {
75
+ floatingElementRef.current.style.height = '';
76
+ }
77
+ });
78
+ return prevHeight;
79
+ }
56
80
  requestAnimationFrame(() => {
57
81
  floatingElementRef.current.style.height = `${prevHeight}px`;
58
82
  });
@@ -63,15 +87,15 @@ function useAnchoredPosition(settings, dependencies = []) {
63
87
  return heightUpdated;
64
88
  };
65
89
  const updatePosition = React.useCallback(() => {
66
- var _floatingElementRef$c5;
90
+ var _floatingElementRef$c3;
67
91
  if (!enabled) return;
68
92
  if (floatingElementRef.current instanceof Element && anchorElementRef.current instanceof Element) {
69
93
  const newPosition = getAnchoredPosition(floatingElementRef.current, anchorElementRef.current, settings);
70
94
  setPosition(prev => {
71
95
  if (settings !== null && settings !== void 0 && settings.pinPosition && topPositionChanged(prev, newPosition)) {
72
- var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$c3, _floatingElementRef$c4;
96
+ var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$c, _floatingElementRef$c2;
73
97
  const anchorTop = (_anchorElementRef$cur = (_anchorElementRef$cur2 = anchorElementRef.current) === null || _anchorElementRef$cur2 === void 0 ? void 0 : _anchorElementRef$cur2.getBoundingClientRect().top) !== null && _anchorElementRef$cur !== void 0 ? _anchorElementRef$cur : 0;
74
- const elementStillFitsOnTop = anchorTop > ((_floatingElementRef$c3 = (_floatingElementRef$c4 = floatingElementRef.current) === null || _floatingElementRef$c4 === void 0 ? void 0 : _floatingElementRef$c4.clientHeight) !== null && _floatingElementRef$c3 !== void 0 ? _floatingElementRef$c3 : 0);
98
+ const elementStillFitsOnTop = anchorTop > ((_floatingElementRef$c = (_floatingElementRef$c2 = floatingElementRef.current) === null || _floatingElementRef$c2 === void 0 ? void 0 : _floatingElementRef$c2.clientHeight) !== null && _floatingElementRef$c !== void 0 ? _floatingElementRef$c : 0);
75
99
  if (elementStillFitsOnTop && updateElementHeight()) {
76
100
  return prev;
77
101
  }
@@ -88,9 +112,9 @@ function useAnchoredPosition(settings, dependencies = []) {
88
112
  setPosition(undefined);
89
113
  (_savedOnPositionChang2 = savedOnPositionChange.current) === null || _savedOnPositionChang2 === void 0 ? void 0 : _savedOnPositionChang2.call(savedOnPositionChange, undefined);
90
114
  }
91
- setPrevHeight((_floatingElementRef$c5 = floatingElementRef.current) === null || _floatingElementRef$c5 === void 0 ? void 0 : _floatingElementRef$c5.clientHeight);
115
+ setPrevHeight((_floatingElementRef$c3 = floatingElementRef.current) === null || _floatingElementRef$c3 === void 0 ? void 0 : _floatingElementRef$c3.clientHeight);
92
116
  },
93
- // eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
94
118
  [floatingElementRef, anchorElementRef, enabled, ...dependencies]);
95
119
  useIsomorphicLayoutEffect(() => {
96
120
  savedOnPositionChange.current = settings === null || settings === void 0 ? void 0 : settings.onPositionChange;
@@ -1,11 +1,3 @@
1
1
  import { type RefObject } from 'react';
2
- /**
3
- * Returns a function that focuses the given element on the next render commit.
4
- *
5
- * The target is stored in a ref (not state) and the effect is gated by a
6
- * version counter, so calling `focus()` produces exactly one render — never
7
- * the two-render cascade you'd get from `setState(target)` followed by
8
- * `setState(null)` inside the effect.
9
- */
10
- export declare function useFocus(): (target: HTMLElement | RefObject<HTMLElement>) => void;
2
+ export declare function useFocus(): import("react").Dispatch<import("react").SetStateAction<HTMLElement | RefObject<HTMLElement> | null>>;
11
3
  //# sourceMappingURL=useFocus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFocus.d.ts","sourceRoot":"","sources":["../../../src/internal/hooks/useFocus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,SAAS,EAA2C,MAAM,OAAO,CAAA;AAE9E;;;;;;;GAOG;AACH,wBAAgB,QAAQ,aAgBM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC,UAIjE"}
1
+ {"version":3,"file":"useFocus.d.ts","sourceRoot":"","sources":["../../../src/internal/hooks/useFocus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAA;AAEzD,wBAAgB,QAAQ,0GAmBvB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260522115117",
4
+ "version": "0.0.0-20260522120829",
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",
@@ -1,35 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- export type RenderCounter = {
3
- /** Total number of times the wrapped subtree has rendered (mount + updates). */
4
- readonly count: number;
5
- /** Number of mount renders. */
6
- readonly mountCount: number;
7
- /** Number of update renders (any cause). */
8
- readonly updateCount: number;
9
- /**
10
- * Number of updates triggered inside the same commit cycle that produced the
11
- * original render — i.e., a `setState` call from inside a `useLayoutEffect`
12
- * that forced a synchronous re-render before paint. This is the canonical
13
- * "nested update" / cascade signal; assert `nestedUpdateCount === 0` to pin
14
- * that a component never forces a double-commit.
15
- */
16
- readonly nestedUpdateCount: number;
17
- /** Reset the counter. */
18
- reset(): void;
19
- };
20
- /**
21
- * Returns a `[Wrap, counter]` pair. Wrap the component under test with `Wrap`
22
- * to count how many times its subtree renders. Useful for asserting that a
23
- * single user interaction (or a stable prop) does not cause cascading renders.
24
- *
25
- * @example
26
- * const [Wrap, counter] = createRenderCounter()
27
- * render(<Wrap><MyComponent /></Wrap>)
28
- * // ... interaction ...
29
- * expect(counter.updateCount).toBe(1)
30
- * expect(counter.nestedUpdateCount).toBe(0)
31
- */
32
- export declare function createRenderCounter(id?: string): [(props: {
33
- children: ReactElement | ReactElement[];
34
- }) => ReactElement, RenderCounter];
35
- //# sourceMappingURL=profiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../../src/utils/testing/profiler.tsx"],"names":[],"mappings":"AAAA,OAAc,EAA0C,KAAK,YAAY,EAAC,MAAM,OAAO,CAAA;AAEvF,MAAM,MAAM,aAAa,GAAG;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC,yBAAyB;IACzB,KAAK,IAAI,IAAI,CAAA;CACd,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,SAAkB,GACnB,CAAC,CAAC,KAAK,EAAE;IAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;CAAC,KAAK,YAAY,EAAE,aAAa,CAAC,CAsCrF"}