@sanity/ui 2.3.6-canary.5 → 2.3.6-canary.6

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.3.6-canary.5",
3
+ "version": "2.3.6-canary.6",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -14,6 +14,7 @@ import {AnimatePresence} from 'framer-motion'
14
14
  import {
15
15
  MutableRefObject,
16
16
  RefCallback,
17
+ cloneElement,
17
18
  forwardRef,
18
19
  memo,
19
20
  useCallback,
@@ -133,7 +134,7 @@ export const Popover = memo(
133
134
  animate: _animate = false,
134
135
  arrow: arrowProp = false,
135
136
  boundaryElement: _boundaryElement,
136
- children,
137
+ children: _children,
137
138
  constrainSize = false,
138
139
  content,
139
140
  disabled,
@@ -366,12 +367,23 @@ export const Popover = memo(
366
367
  useImperativeHandle(updateRef, () => update, [update])
367
368
 
368
369
  useEffect(() => {
369
- if (children) return
370
+ if (_children) return
370
371
  refs.setReference(referenceElement || null)
371
- }, [children, referenceElement, refs])
372
+ }, [_children, referenceElement, refs])
373
+
374
+ const children = useMemo(() => {
375
+ if (!_children || referenceElement) return null
376
+
377
+ return cloneElement(_children, {
378
+ ref: (node: HTMLDivElement | null): void => {
379
+ logDeprecatedWarning()
380
+ refs.setReference(node)
381
+ },
382
+ })
383
+ }, [_children, referenceElement, refs])
372
384
 
373
385
  if (disabled) {
374
- return children || <></>
386
+ return _children || <></>
375
387
  }
376
388
 
377
389
  const popover = (
@@ -426,18 +438,8 @@ export const Popover = memo(
426
438
  )}
427
439
  </ConditionalWrapper>
428
440
 
429
- {/* the referred element */}
430
- {children && !referenceElement && (
431
- <div
432
- ref={(node) => {
433
- logDeprecatedWarning()
434
- refs.setReference(node)
435
- }}
436
- style={{display: 'contents'}}
437
- >
438
- {children}
439
- </div>
440
- )}
441
+ {/* the referred element (legacy, use referenceElement instead) */}
442
+ {children}
441
443
  </>
442
444
  )
443
445
  }),