@sanity/ui 0.37.14 → 0.37.15

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.
@@ -6774,7 +6774,7 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6774
6774
  const [popperElement, setPopperElement] = useState(null);
6775
6775
  const [arrowElement, setArrowElement] = useState(null);
6776
6776
  const popperReferenceElement = referenceElementProp || referenceElement;
6777
- const width = useArrayProp(widthProp);
6777
+ const width = useArrayProp(matchReferenceWidth ? 'auto' : widthProp);
6778
6778
  const modifiers = usePopoverModifiers({
6779
6779
  allowedAutoPlacements,
6780
6780
  arrow,
@@ -6815,13 +6815,21 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6815
6815
  forwardedRef.current = el;
6816
6816
  }, [forwardedRef]);
6817
6817
  const popoverStyle = useMemo(() => _extends({}, style, styles.popper), [style, styles]);
6818
+ const updateTimeoutRef = useRef(null);
6818
6819
  useEffect(() => {
6819
- if (forceUpdate) {
6820
- try {
6821
- forceUpdate();
6822
- } catch (_) {// ignore caught error
6823
- }
6820
+ if (updateTimeoutRef.current) {
6821
+ clearTimeout(updateTimeoutRef.current);
6822
+ updateTimeoutRef.current = null;
6824
6823
  }
6824
+
6825
+ updateTimeoutRef.current = setTimeout(() => {
6826
+ if (forceUpdate) {
6827
+ try {
6828
+ forceUpdate();
6829
+ } catch (_) {// ignore caught error
6830
+ }
6831
+ }
6832
+ }, 0);
6825
6833
  }, [content, forceUpdate, open, popperReferenceElement]);
6826
6834
 
6827
6835
  if (disabled) {
@@ -7894,13 +7902,21 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
7894
7902
  window.removeEventListener('mousemove', handleWindowMouseMove);
7895
7903
  };
7896
7904
  }, [isOpen, referenceElement]);
7905
+ const updateTimeoutRef = useRef(null);
7897
7906
  useEffect(() => {
7898
- if (forceUpdate) {
7899
- try {
7900
- forceUpdate();
7901
- } catch (_) {// ignore caught error
7902
- }
7907
+ if (updateTimeoutRef.current) {
7908
+ clearTimeout(updateTimeoutRef.current);
7909
+ updateTimeoutRef.current = null;
7903
7910
  }
7911
+
7912
+ updateTimeoutRef.current = setTimeout(() => {
7913
+ if (forceUpdate) {
7914
+ try {
7915
+ forceUpdate();
7916
+ } catch (_) {// ignore caught error
7917
+ }
7918
+ }
7919
+ }, 0);
7904
7920
  }, [forceUpdate, content]); // Close when `disabled` changes to `true`
7905
7921
 
7906
7922
  useEffect(() => {