[Editor] Make sure the editor is focused after the comment has been deleted (bug 1992832)

This commit is contained in:
Calixte Denizet 2025-10-07 20:38:02 +02:00
parent 1df2ee68b7
commit 76e0de6c08
2 changed files with 38 additions and 0 deletions

View File

@ -699,5 +699,42 @@ describe("Comment", () => {
})
);
});
it("must check that the focus is moved on the editor once the popup is deleted", async () => {
await Promise.all(
pages.map(async ([, page]) => {
await switchToHighlight(page);
await highlightSpan(page, 1, "Abstract");
const editorSelector = getEditorSelector(0);
await editComment(page, editorSelector, "Hello world!");
await waitAndClick(
page,
`${editorSelector} button.annotationCommentButton`
);
const popupSelector = "#commentPopup";
await page.waitForSelector(popupSelector, { visible: true });
const handle = await page.evaluateHandle(
sel => [
new Promise(resolve => {
document
.querySelector(sel)
.addEventListener("focusin", resolve, {
once: true,
});
}),
],
editorSelector
);
await waitAndClick(
page,
`${popupSelector} button.commentPopupDelete`
);
await awaitPromise(handle);
})
);
});
});
});

View File

@ -1048,6 +1048,7 @@ class CommentPopup {
},
});
this.#editor.comment = null;
this.#editor.focus();
this.destroy();
});
del.addEventListener("contextmenu", noContextMenu);