@primer/react 0.0.0-20260707193314 → 0.0.0-20260707195911

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-20260707193314
3
+ ## 0.0.0-20260707195911
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -19,9 +19,9 @@
19
19
 
20
20
  - Fake entry to force publishing
21
21
 
22
- - [#8115](https://github.com/primer/react/pull/8115) [`07c530a`](https://github.com/primer/react/commit/07c530a1686ef16b68b2f2fe692b7a3327bdc02b) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Improve rendering performance in Safari by removing expensive `:has()` selectors from ActionList/NavList, Breadcrumbs, SelectPanel, and SegmentedControl. No visual or API changes.
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.
23
23
 
24
- - [#7904](https://github.com/primer/react/pull/7904) [`9683f3f`](https://github.com/primer/react/commit/9683f3f099ed9fcc46a7ac110cbea07256e339f0) Thanks [@mattcosta7](https://github.com/mattcosta7)! - SelectPanel (experimental v2): replace the `:has(input:placeholder-shown)` selector that hid the clear-action button with a `data-empty` attribute derived from React state. The clear-action visibility no longer triggers a descendant `:has()` re-evaluation on every keystroke.
24
+ - [#8115](https://github.com/primer/react/pull/8115) [`07c530a`](https://github.com/primer/react/commit/07c530a1686ef16b68b2f2fe692b7a3327bdc02b) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Improve rendering performance in Safari by removing expensive `:has()` selectors from ActionList/NavList, Breadcrumbs, SelectPanel, and SegmentedControl. No visual or API changes.
25
25
 
26
26
  - [#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.
27
27
 
@@ -276,15 +276,9 @@ SelectPanelHeader.__SLOT__ = Symbol("SelectPanel.Header");
276
276
  const SelectPanelSearchInput = ({ onChange: propsOnChange, onKeyDown: propsOnKeyDown, className, ...props }) => {
277
277
  const inputRef = /*#__PURE__*/ React.createRef();
278
278
  const { setSearchQuery, moveFocusToList } = React.useContext(SelectPanelContext);
279
- const [uncontrolledEmpty, setUncontrolledEmpty] = React.useState(() => {
280
- var _ref, _props$value;
281
- return ((_ref = (_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : props.defaultValue) !== null && _ref !== void 0 ? _ref : "") === "";
282
- });
283
- const isEmpty = props.value !== void 0 ? props.value === "" : uncontrolledEmpty;
284
279
  const internalOnChange = (event) => {
285
280
  if (typeof propsOnChange === "function") propsOnChange(event);
286
281
  else setSearchQuery(event.target.value);
287
- setUncontrolledEmpty(event.target.value === "");
288
282
  };
289
283
  const internalKeyDown = (event) => {
290
284
  if (event.key === "ArrowDown") {
@@ -309,14 +303,12 @@ const SelectPanelSearchInput = ({ onChange: propsOnChange, onKeyDown: propsOnKey
309
303
  target: inputRef.current,
310
304
  currentTarget: inputRef.current
311
305
  });
312
- setUncontrolledEmpty(true);
313
306
  }
314
307
  }),
315
308
  className: clsx(SelectPanel_module_css_default.TextInput, className),
316
309
  onChange: internalOnChange,
317
310
  onKeyDown: internalKeyDown,
318
- ...props,
319
- "data-empty": isEmpty || void 0
311
+ ...props
320
312
  });
321
313
  };
322
314
  SelectPanelSearchInput.displayName = "SelectPanelSearchInput";
@@ -106,6 +106,10 @@ 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
+ });
109
113
  React.useEffect(() => {
110
114
  if (!enabled) return;
111
115
  const anchorEl = anchorElementRef.current;
@@ -118,7 +122,16 @@ function useAnchoredPosition(settings, dependencies = []) {
118
122
  updatePosition();
119
123
  });
120
124
  };
121
- const scrollables = getScrollableAncestors(anchorEl);
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
+ }
122
135
  for (const scrollable of scrollables) scrollable.addEventListener("scroll", handleScroll);
123
136
  return () => {
124
137
  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-20260707193314",
4
+ "version": "0.0.0-20260707195911",
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",