@primer/react 0.0.0-20260707170941 → 0.0.0-20260707171001

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,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260707170941
3
+ ## 0.0.0-20260707171001
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -19,7 +19,7 @@
19
19
 
20
20
  - Fake entry to force publishing
21
21
 
22
- - [#8116](https://github.com/primer/react/pull/8116) [`064b105`](https://github.com/primer/react/commit/064b105604e31486806b8f4ab432540aaca10465) Thanks [@mattcosta7](https://github.com/mattcosta7)! - `useAnchoredPosition`: improve performance by caching the scrollable-ancestor walk per anchor, reducing repositioning work for overlays, menus, and tooltips.
22
+ - [#8025](https://github.com/primer/react/pull/8025) [`5abc62f`](https://github.com/primer/react/commit/5abc62f90cac33cd67396d78f01bf91b703db45c) Thanks [@mattcosta7](https://github.com/mattcosta7)! - SelectPanel: Reset the single-select modal's intermediate selection during render instead of in an effect, avoiding an extra re-render when the panel opens or the selection changes.
23
23
 
24
24
  - [#8035](https://github.com/primer/react/pull/8035) [`723f4d6`](https://github.com/primer/react/commit/723f4d6db12710e2b94f56b945a937158fcbb127) Thanks [@mattcosta7](https://github.com/mattcosta7)! - UnderlineNav, ActionBar: Detect item overflow with a single shared IntersectionObserver per component instead of one observer per item, reducing observer churn during resize. No public API changes.
25
25
 
@@ -99,13 +99,20 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
99
99
  const selectedValueId = id ? `${id}-selected-value` : void 0;
100
100
  const isSingleSelectModal = variant === "modal" && !isMultiSelectVariant(selected);
101
101
  const [intermediateSelected, setIntermediateSelected] = useState(isSingleSelectModal ? selected : void 0);
102
- useEffect(() => {
103
- setIntermediateSelected(isSingleSelectModal ? selected : void 0);
104
- }, [
105
- isSingleSelectModal,
102
+ const nextIntermediateSelected = isSingleSelectModal ? selected : void 0;
103
+ const [intermediateSelectedResetKey, setIntermediateSelectedResetKey] = useState({
106
104
  open,
107
- selected
108
- ]);
105
+ selected,
106
+ isSingleSelectModal
107
+ });
108
+ if ((intermediateSelectedResetKey.open !== open || intermediateSelectedResetKey.selected !== selected || intermediateSelectedResetKey.isSingleSelectModal !== isSingleSelectModal) && intermediateSelected !== nextIntermediateSelected) {
109
+ setIntermediateSelectedResetKey({
110
+ open,
111
+ selected,
112
+ isSingleSelectModal
113
+ });
114
+ setIntermediateSelected(nextIntermediateSelected);
115
+ }
109
116
  const onListContainerRefChanged = useCallback((node) => {
110
117
  setListContainerElement(node);
111
118
  if (!node && needsNoItemsAnnouncement) setNeedsNoItemsAnnouncement(false);
@@ -106,10 +106,6 @@ function useAnchoredPosition(settings, dependencies = []) {
106
106
  }, [updatePosition]);
107
107
  useResizeObserver(updatePosition, void 0, [], enabled);
108
108
  useResizeObserver(updatePosition, floatingElementRef, [], enabled);
109
- const scrollAncestorsCacheRef = React.useRef({
110
- anchor: null,
111
- scrollables: []
112
- });
113
109
  React.useEffect(() => {
114
110
  if (!enabled) return;
115
111
  const anchorEl = anchorElementRef.current;
@@ -122,16 +118,7 @@ function useAnchoredPosition(settings, dependencies = []) {
122
118
  updatePosition();
123
119
  });
124
120
  };
125
- const cache = scrollAncestorsCacheRef.current;
126
- let scrollables;
127
- if (cache.anchor === anchorEl) scrollables = cache.scrollables;
128
- else {
129
- scrollables = getScrollableAncestors(anchorEl);
130
- scrollAncestorsCacheRef.current = {
131
- anchor: anchorEl,
132
- scrollables
133
- };
134
- }
121
+ const scrollables = getScrollableAncestors(anchorEl);
135
122
  for (const scrollable of scrollables) scrollable.addEventListener("scroll", handleScroll);
136
123
  return () => {
137
124
  for (const scrollable of scrollables) scrollable.removeEventListener("scroll", handleScroll);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260707170941",
4
+ "version": "0.0.0-20260707171001",
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",