From 72e343c379b1d060fb8b0013d63fa1b27e3be6ce Mon Sep 17 00:00:00 2001 From: Flrande <1978616327@qq.com> Date: Thu, 2 Jan 2025 08:25:48 +0000 Subject: [PATCH] fix(editor): replace checkVisibility (#9481) --- blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts b/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts index 07e2bcf397..65729730ca 100644 --- a/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts +++ b/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts @@ -14,7 +14,8 @@ import { DropFlags, type DroppingType, type DropResult } from './types.js'; function getVisiblePreviousElementSibling(element: Element | null) { if (!element) return null; let prev = element.previousElementSibling; - while (prev && !prev.checkVisibility()) { + // https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom + while (prev instanceof HTMLElement && prev.offsetParent === null) { prev = prev.previousElementSibling; } return prev; @@ -23,7 +24,7 @@ function getVisiblePreviousElementSibling(element: Element | null) { function getVisibleNextElementSibling(element: Element | null) { if (!element) return null; let next = element.nextElementSibling; - while (next && !next.checkVisibility()) { + while (next instanceof HTMLElement && next.offsetParent === null) { next = next.nextElementSibling; } return next;