From 2bf34fbf1e0d90560e52dec4fabac78e800a8a4e Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:43:27 -0800 Subject: [PATCH] Fix useHasWrapped hook --- ts/hooks/useHasWrapped.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ts/hooks/useHasWrapped.ts b/ts/hooks/useHasWrapped.ts index 4b10e2821..d5a9cab19 100644 --- a/ts/hooks/useHasWrapped.ts +++ b/ts/hooks/useHasWrapped.ts @@ -5,6 +5,10 @@ import type { Ref } from 'react'; import { useEffect, useState } from 'react'; import { first, last, noop } from 'lodash'; +function getBottom(element: Readonly): number { + return element.getBoundingClientRect().bottom; +} + function getTop(element: Readonly): number { return element.getBoundingClientRect().top; } @@ -22,7 +26,7 @@ function isWrapped(element: Readonly): boolean { firstChild && lastChild && firstChild !== lastChild && - getTop(firstChild) !== getTop(lastChild) + getBottom(firstChild) <= getTop(lastChild) ); }