@sanity/ui 1.7.10 → 1.7.11

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": "1.7.10",
3
+ "version": "1.7.11",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "source": "./src/index.ts",
@@ -8,7 +8,6 @@ import {
8
8
  useFloating,
9
9
  Middleware,
10
10
  RootBoundary,
11
- size,
12
11
  } from '@floating-ui/react-dom'
13
12
  import {
14
13
  cloneElement,
@@ -91,25 +90,12 @@ export const Tooltip = forwardRef(function Tooltip(
91
90
  fallbackPlacements,
92
91
  padding: 4,
93
92
  rootBoundary,
94
- mainAxis: false,
95
93
  }),
96
94
  )
97
95
 
98
96
  // Define distance between reference and floating element
99
97
  ret.push(offset({mainAxis: 3}))
100
98
 
101
- // Set width and height on the floating element
102
- ret.push(
103
- size({
104
- apply({availableWidth, availableHeight, elements}) {
105
- Object.assign(elements.floating.style, {
106
- maxWidth: `${availableWidth - 4 * 2}px`, // the padding is `4px`
107
- maxHeight: `${availableHeight - 4 * 2}px`, // the padding is `4px`
108
- })
109
- },
110
- }),
111
- )
112
-
113
99
  // Shift the tooltip so its sits with the boundary eleement
114
100
  ret.push(
115
101
  shift({
@@ -125,12 +111,21 @@ export const Tooltip = forwardRef(function Tooltip(
125
111
  return ret
126
112
  }, [boundaryElement, fallbackPlacements])
127
113
 
128
- const {floatingStyles, placement, middlewareData, refs, update} = useFloating({
114
+ const {x, y, placement, middlewareData, refs, update, strategy} = useFloating({
129
115
  middleware,
130
116
  placement: placementProp,
131
117
  whileElementsMounted: autoUpdate,
132
118
  })
133
119
 
120
+ const rootStyle: CSSProperties = useMemo(
121
+ () => ({
122
+ position: strategy,
123
+ top: y ?? 0,
124
+ left: x ?? 0,
125
+ }),
126
+ [strategy, x, y],
127
+ )
128
+
134
129
  const staticSide = placement && FLOATING_STATIC_SIDES[placement.split('-')[0]]
135
130
 
136
131
  const arrowX = middlewareData.arrow?.x
@@ -243,13 +238,7 @@ export const Tooltip = forwardRef(function Tooltip(
243
238
  if (disabled) return child
244
239
 
245
240
  const root = (
246
- <Root
247
- data-ui="Tooltip"
248
- {...restProps}
249
- ref={setFloating}
250
- style={floatingStyles}
251
- zOffset={zOffset}
252
- >
241
+ <Root data-ui="Tooltip" {...restProps} ref={setFloating} style={rootStyle} zOffset={zOffset}>
253
242
  <Card
254
243
  data-ui="Tooltip__card"
255
244
  data-placement={placement}