Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): replace checkVisibility (#9481)

Flrande72e343c379b1
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;