fix: Incorrect menu position when notice is first item in doc, closes #8539

This commit is contained in:
Tom Moor
2025-02-23 11:00:42 -05:00
parent 17f4dc58f1
commit 4ad58b4ccd
2 changed files with 3 additions and 5 deletions

View File

@@ -89,7 +89,7 @@ function usePosition({
? noticeBlock.pos
: null;
if (position) {
if (position !== null) {
const element = view.nodeDOM(position);
const bounds = (element as HTMLElement).getBoundingClientRect();
selectionBounds.top = bounds.top;

View File

@@ -16,10 +16,8 @@ export default function noticeMenuItems(
readOnly: boolean | undefined,
dictionary: Dictionary
): MenuItem[] {
const { selection } = state;
const { $from } = selection;
const node = $from.node(-1);
const currentStyle = node.attrs.style as NoticeTypes;
const node = state.selection.$from.node(-1);
const currentStyle = node?.attrs.style as NoticeTypes;
const mapping = {
[NoticeTypes.Info]: dictionary.infoNotice,