@primer/react 0.0.0-20260311170109 → 0.0.0-20260311173344

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,12 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260311170109
3
+ ## 0.0.0-20260311173344
4
+
5
+ ### Patch Changes
6
+
7
+ - Fake entry to force publishing
8
+
9
+ ## 38.15.0
4
10
 
5
11
  ### Minor Changes
6
12
 
@@ -12,8 +18,6 @@
12
18
 
13
19
  - [#7529](https://github.com/primer/react/pull/7529) [`7e108fe`](https://github.com/primer/react/commit/7e108fea1a9f92ce22f46ff1d55bfe4753d89ad8) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Add keyboard-accessible tooltip for truncated ActionList.Description
14
20
 
15
- - Fake entry to force publishing
16
-
17
21
  - [#7585](https://github.com/primer/react/pull/7585) [`3dd2c78`](https://github.com/primer/react/commit/3dd2c78f768ad560ee0f37947af2c17ca8d7938c) Thanks [@iansan5653](https://github.com/iansan5653)! - - Fixes a bug where `ActionBar` menu items would be out of order if new items were mounted after the initial render
18
22
 
19
23
  - Improves initial render performance for `ActionBar`
@@ -1 +1 @@
1
- {"version":3,"file":"useAnchoredPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnchoredPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AAKvE,MAAM,WAAW,4BAA6B,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IAC7E,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACpD,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,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,EAAE,cAAc,GAAG,SAAS,CAAA;CACrC,CA2GA"}
@@ -4,6 +4,26 @@ import { useProvidedRefOrCreate } from './useProvidedRefOrCreate.js';
4
4
  import { useResizeObserver } from './useResizeObserver.js';
5
5
  import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
6
6
 
7
+ /**
8
+ * Returns all scrollable ancestor elements of the given element, plus the window.
9
+ * An element is scrollable if its computed overflow/overflow-x/overflow-y is
10
+ * 'auto', 'scroll', or 'overlay'.
11
+ */
12
+ function getScrollableAncestors(element) {
13
+ const scrollables = [];
14
+ let current = element.parentElement;
15
+ while (current) {
16
+ const style = getComputedStyle(current);
17
+ const overflowY = style.overflowY;
18
+ const overflowX = style.overflowX;
19
+ if (/auto|scroll|overlay/.test(overflowY) || /auto|scroll|overlay/.test(overflowX)) {
20
+ scrollables.push(current);
21
+ }
22
+ current = current.parentElement;
23
+ }
24
+ scrollables.push(window);
25
+ return scrollables;
26
+ }
7
27
  /**
8
28
  * Calculates the top and left values for an absolutely-positioned floating element
9
29
  * to be anchored to some anchor element. Returns refs for the floating element
@@ -76,6 +96,32 @@ function useAnchoredPosition(settings, dependencies = []) {
76
96
  useResizeObserver(updatePosition); // watches for changes in window size
77
97
  useResizeObserver(updatePosition, floatingElementRef); // watches for changes in floating element size
78
98
 
99
+ // Recalculate position when any scrollable ancestor of the anchor scrolls.
100
+ // Uses requestAnimationFrame to avoid layout thrashing during scroll.
101
+ React.useEffect(() => {
102
+ const anchorEl = anchorElementRef.current;
103
+ if (!anchorEl) return;
104
+ let rafId = null;
105
+ const handleScroll = () => {
106
+ if (rafId !== null) return;
107
+ rafId = requestAnimationFrame(() => {
108
+ rafId = null;
109
+ updatePosition();
110
+ });
111
+ };
112
+ const scrollables = getScrollableAncestors(anchorEl);
113
+ for (const scrollable of scrollables) {
114
+ scrollable.addEventListener('scroll', handleScroll);
115
+ }
116
+ return () => {
117
+ for (const scrollable of scrollables) {
118
+ scrollable.removeEventListener('scroll', handleScroll);
119
+ }
120
+ if (rafId !== null) {
121
+ cancelAnimationFrame(rafId);
122
+ }
123
+ };
124
+ }, [anchorElementRef, updatePosition]);
79
125
  return {
80
126
  floatingElementRef,
81
127
  anchorElementRef,
@@ -1759,7 +1759,7 @@
1759
1759
  },
1760
1760
  {
1761
1761
  "id": "components-button-features--inactive",
1762
- "code": "() => (\n <div\n style={{\n display: 'flex',\n flexWrap: 'wrap',\n flexDirection: 'row',\n gap: '1rem',\n }}\n >\n <VisuallyHidden id=\"inactive-state\">Inactive</VisuallyHidden>\n <Button inactive aria-describedby=\"inactive-state\">\n Default\n </Button>\n <Button variant=\"primary\" inactive aria-describedby=\"inactive-state\">\n Primary\n </Button>\n <Button variant=\"danger\" inactive aria-describedby=\"inactive-state\">\n Danger\n </Button>\n <Button variant=\"invisible\" inactive aria-describedby=\"inactive-state\">\n Invisible\n </Button>\n </div>\n)"
1762
+ "code": "() => (\n <div\n style={{\n display: 'flex',\n flexDirection: 'row',\n gap: '1rem',\n }}\n >\n <VisuallyHidden id=\"inactive-state\">Inactive</VisuallyHidden>\n <Button inactive aria-describedby=\"inactive-state\">\n Default\n </Button>\n <Button variant=\"primary\" inactive aria-describedby=\"inactive-state\">\n Primary\n </Button>\n <Button variant=\"danger\" inactive aria-describedby=\"inactive-state\">\n Danger\n </Button>\n <Button variant=\"invisible\" inactive aria-describedby=\"inactive-state\">\n Invisible\n </Button>\n </div>\n)"
1763
1763
  },
1764
1764
  {
1765
1765
  "id": "components-button-features--small",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260311170109",
4
+ "version": "0.0.0-20260311173344",
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",