Skip to content

Commit

Permalink
[lexical-react]Bug Fix: the location of draggable-block-menu cannot b…
Browse files Browse the repository at this point in the history
…e calculated #6818 (#6915)

Co-authored-by: Bob Ippolito <[email protected]>
  • Loading branch information
lin-mt and etrepum authored Dec 10, 2024
1 parent dba2540 commit 42bd45d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/lexical-react/src/LexicalDraggableBlockPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,15 @@ function setMenuPosition(
const floatingElemRect = floatingElem.getBoundingClientRect();
const anchorElementRect = anchorElem.getBoundingClientRect();

// top left
let targetCalculateHeight: number = parseInt(targetStyle.lineHeight, 10);
if (isNaN(targetCalculateHeight)) {
// middle
targetCalculateHeight = targetRect.bottom - targetRect.top;
}
const top =
targetRect.top +
(parseInt(targetStyle.lineHeight, 10) - floatingElemRect.height) / 2 -
(targetCalculateHeight - floatingElemRect.height) / 2 -
anchorElementRect.top;

const left = SPACE;
Expand Down

0 comments on commit 42bd45d

Please sign in to comment.