@sanity/ui 2.8.9 → 2.8.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.8.9",
3
+ "version": "2.8.10",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -125,20 +125,20 @@
125
125
  "@sanity/prettier-config": "^1.0.2",
126
126
  "@sanity/semantic-release-preset": "^5.0.0",
127
127
  "@sanity/ui-workshop": "^2.0.16",
128
- "@storybook/addon-a11y": "^8.2.8",
129
- "@storybook/addon-docs": "^8.2.8",
130
- "@storybook/addon-essentials": "^8.2.8",
131
- "@storybook/addon-interactions": "^8.2.8",
132
- "@storybook/addon-links": "^8.2.8",
133
- "@storybook/addon-mdx-gfm": "^8.2.8",
134
- "@storybook/addon-storysource": "^8.2.8",
135
- "@storybook/addon-themes": "^8.2.8",
136
- "@storybook/blocks": "^8.2.8",
137
- "@storybook/manager-api": "^8.2.8",
138
- "@storybook/react": "^8.2.8",
139
- "@storybook/react-vite": "^8.2.8",
140
- "@storybook/test": "^8.2.8",
141
- "@storybook/theming": "^8.2.8",
128
+ "@storybook/addon-a11y": "^8.2.9",
129
+ "@storybook/addon-docs": "^8.2.9",
130
+ "@storybook/addon-essentials": "^8.2.9",
131
+ "@storybook/addon-interactions": "^8.2.9",
132
+ "@storybook/addon-links": "^8.2.9",
133
+ "@storybook/addon-mdx-gfm": "^8.2.9",
134
+ "@storybook/addon-storysource": "^8.2.9",
135
+ "@storybook/addon-themes": "^8.2.9",
136
+ "@storybook/blocks": "^8.2.9",
137
+ "@storybook/manager-api": "^8.2.9",
138
+ "@storybook/react": "^8.2.9",
139
+ "@storybook/react-vite": "^8.2.9",
140
+ "@storybook/test": "^8.2.9",
141
+ "@storybook/theming": "^8.2.9",
142
142
  "@testing-library/dom": "^10.4.0",
143
143
  "@testing-library/jest-dom": "^6.4.8",
144
144
  "@testing-library/react": "^16.0.0",
@@ -182,7 +182,7 @@
182
182
  "rimraf": "^5.0.5",
183
183
  "semantic-release": "^24.0.0",
184
184
  "start-server-and-test": "^2.0.5",
185
- "storybook": "^8.2.8",
185
+ "storybook": "^8.2.9",
186
186
  "styled-components": "^6.1.12",
187
187
  "tsconfig-paths": "^4.2.0",
188
188
  "typescript": "5.5.3",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import {
2
3
  Middleware,
3
4
  RootBoundary,
@@ -359,8 +360,7 @@ export const Popover = memo(
359
360
  (node: HTMLElement | null) => {
360
361
  refs.setReference(node)
361
362
 
362
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
363
- const childRef = (childProp as any)?.ref
363
+ const childRef = getElementRef(childProp as any)
364
364
 
365
365
  if (typeof childRef === 'function') {
366
366
  childRef(node)
@@ -455,3 +455,29 @@ export const Popover = memo(
455
455
  }),
456
456
  )
457
457
  Popover.displayName = 'Memo(ForwardRef(Popover))'
458
+
459
+ // Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`
460
+ // After React 19 accessing `element.ref` does the opposite.
461
+ // https://github.com/facebook/react/pull/28348
462
+ //
463
+ // Access the ref using the method that doesn't yield a warning.
464
+ function getElementRef(element: React.ReactElement) {
465
+ // React <=18 in DEV
466
+ let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get
467
+ let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
468
+
469
+ if (mayWarn) {
470
+ return (element as any).ref
471
+ }
472
+
473
+ // React 19 in DEV
474
+ getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get
475
+ mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
476
+
477
+ if (mayWarn) {
478
+ return element.props.ref
479
+ }
480
+
481
+ // Not DEV
482
+ return element.props.ref || (element as any).ref
483
+ }