Skip to content

Commit

Permalink
fix menu location
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Oct 12, 2024
1 parent 911d770 commit 2bf0eed
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ export class FloatingMenuView {
return;
}

const { top: containerTop } = view.dom.getBoundingClientRect();
const { top: containerTop, left: containerLeft } =
view.dom.getBoundingClientRect();
const { bottom: caretY } = posToDOMRect(view, from, to);
const offsetY = caretY - containerTop + 16;
const offsetY = caretY + 16;
const offsetX = containerLeft;

// NOTE: Left is -1px for optical alignment due to the border radius.
this.element.setAttribute("style", `top: ${offsetY}px; left: -1px;`);
this.element.setAttribute(
"style",
`top: ${offsetY}px; left: ${offsetX - 1}px;`,
);
}

hide() {
Expand Down

0 comments on commit 2bf0eed

Please sign in to comment.