From 76e0de6c0874a9f6dc89ca9a4ffac30b6e27f76b Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 7 Oct 2025 20:38:02 +0200 Subject: [PATCH] [Editor] Make sure the editor is focused after the comment has been deleted (bug 1992832) --- test/integration/comment_spec.mjs | 37 +++++++++++++++++++++++++++++++ web/comment_manager.js | 1 + 2 files changed, 38 insertions(+) diff --git a/test/integration/comment_spec.mjs b/test/integration/comment_spec.mjs index 93195dc88..a08e63544 100644 --- a/test/integration/comment_spec.mjs +++ b/test/integration/comment_spec.mjs @@ -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); + }) + ); + }); }); }); diff --git a/web/comment_manager.js b/web/comment_manager.js index 4add97b73..572df94c5 100644 --- a/web/comment_manager.js +++ b/web/comment_manager.js @@ -1048,6 +1048,7 @@ class CommentPopup { }, }); this.#editor.comment = null; + this.#editor.focus(); this.destroy(); }); del.addEventListener("contextmenu", noContextMenu);