@primer/react 0.0.0-20260630224830 → 0.0.0-20260630235402

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-20260630224830
3
+ ## 0.0.0-20260630235402
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/TooltipV2/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,yBAAyB,EAAC,MAAM,OAAO,CAAA;AASnG,OAAO,EAAoD,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAA;AAI7G,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AAG9C,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAA;AAChF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACjD,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAAA;IAC9B,cAAc,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAA;IACjF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACnC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAC,GACA,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AAmEnC,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAC7C,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CACvE,GACC,UAmSD,CAAA"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/TooltipV2/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,yBAAyB,EAAS,MAAM,OAAO,CAAA;AAS3G,OAAO,EAAoD,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAA;AAI7G,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AAG9C,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAA;AAChF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACjD,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAAA;IAC9B,cAAc,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAA;IACjF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACnC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAC,GACA,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AAmEnC,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAC7C,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CACvE,GACC,UAkTD,CAAA"}
@@ -1,4 +1,4 @@
1
- import React, { Children, useState, useMemo, useEffect } from 'react';
1
+ import React, { Children, useRef, useState, useMemo, useEffect } from 'react';
2
2
  import { invariant } from '../utils/invariant.js';
3
3
  import { warning } from '../utils/warning.js';
4
4
  import { getAnchoredPosition } from '@primer/behaviors';
@@ -11,7 +11,6 @@ import useSafeTimeout from '../hooks/useSafeTimeout.js';
11
11
  import { TooltipContext } from './TooltipContext.js';
12
12
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
13
  import { useId } from '../hooks/useId.js';
14
- import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
15
14
  import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
16
15
  import { getAccessibleKeybindingHintString } from '../KeybindingHint/utils.js';
17
16
  import { KeybindingHint } from '../KeybindingHint/KeybindingHint.js';
@@ -92,8 +91,23 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
92
91
  }, forwardedRef) => {
93
92
  const tooltipId = useId(id);
94
93
  const child = Children.only(children);
95
- const triggerRef = useProvidedRefOrCreate(forwardedRef);
94
+ const childRef = child.ref;
95
+ const triggerRef = useRef(null);
96
96
  const tooltipElRef = React.useRef(null);
97
+
98
+ // Tooltip clones its trigger, so compose refs manually to avoid overwriting the child's original ref
99
+ const assignRef = (ref, node) => {
100
+ if (typeof ref === 'function') {
101
+ ref(node);
102
+ } else if (ref) {
103
+ ref.current = node;
104
+ }
105
+ };
106
+ const setTriggerRef = node => {
107
+ assignRef(triggerRef, node);
108
+ assignRef(childRef, node);
109
+ assignRef(forwardedRef, node);
110
+ };
97
111
  const [calculatedDirection, setCalculatedDirection] = useState(direction);
98
112
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
99
113
  const openTimeoutRef = React.useRef(null);
@@ -206,8 +220,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
206
220
  value: value,
207
221
  children: /*#__PURE__*/jsxs(Fragment, {
208
222
  children: [/*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.cloneElement(child, {
209
- // @ts-expect-error it needs a non nullable ref
210
- ref: triggerRef,
223
+ ref: setTriggerRef,
211
224
  // If it is a type description, we use tooltip to describe the trigger
212
225
  'aria-describedby': (() => {
213
226
  // If tooltip is not a description type, keep the original aria-describedby
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260630224830",
4
+ "version": "0.0.0-20260630235402",
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",