@helpwave/hightide 0.5.3 → 0.5.4

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/dist/index.mjs CHANGED
@@ -8878,8 +8878,11 @@ function useFloatingElement({
8878
8878
  const [style, setStyle] = useState12();
8879
8879
  const isMounted = useIsMounted();
8880
8880
  const calculate = useCallback5(() => {
8881
- const containerRect = containerRef.current.getBoundingClientRect();
8882
- const windowRect = windowRef?.current.getBoundingClientRect() ?? {
8881
+ const containerRect = containerRef.current?.getBoundingClientRect();
8882
+ if (!containerRect) {
8883
+ return;
8884
+ }
8885
+ const windowRect = windowRef?.current?.getBoundingClientRect() ?? {
8883
8886
  top: 0,
8884
8887
  bottom: window.innerHeight,
8885
8888
  left: 0,
@@ -8915,6 +8918,9 @@ function useFloatingElement({
8915
8918
  }
8916
8919
  }, [calculate, active, isMounted, height, width]);
8917
8920
  useEffect13(() => {
8921
+ if (!containerRef.current && active) {
8922
+ return;
8923
+ }
8918
8924
  window.addEventListener("resize", calculate);
8919
8925
  let timeout;
8920
8926
  if (isPolling) {
@@ -8926,7 +8932,7 @@ function useFloatingElement({
8926
8932
  clearInterval(timeout);
8927
8933
  }
8928
8934
  };
8929
- }, [calculate, isPolling, pollingInterval]);
8935
+ }, [active, calculate, containerRef, isPolling, pollingInterval]);
8930
8936
  return style;
8931
8937
  }
8932
8938