From c46f75de150f160ea03870289ef8478b6b3d1cb7 Mon Sep 17 00:00:00 2001 From: Bayheck Date: Tue, 27 Aug 2024 10:05:40 +0500 Subject: [PATCH] fix: getClientRectangle method fixed --- src/client/utils/dom.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/utils/dom.ts b/src/client/utils/dom.ts index 8cc00e5a8..ba7d52eaa 100644 --- a/src/client/utils/dom.ts +++ b/src/client/utils/dom.ts @@ -900,5 +900,11 @@ export function getAssociatedElement (el: HTMLElement): HTMLElement | null { } export function getClientRectangle (el: HTMLElement): DOMRect { - return el.getClientRects()[0] ?? el.getBoundingClientRect(); + const rects = el.getClientRects(); + + for (let i = 0; i < rects.length; i++) { + if (rects[i].height > 0 && rects[i].width > 0) + return rects[i]; + } + return el.getBoundingClientRect(); }