Skip to content

Commit 2627416

Browse files
authored
Merge pull request #20343 from calixteman/bug1992832
[Editor] Make sure the editor is focused after the comment has been deleted (bug 1992832)
2 parents 1df2ee6 + 76e0de6 commit 2627416

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/integration/comment_spec.mjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,5 +699,42 @@ describe("Comment", () => {
699699
})
700700
);
701701
});
702+
703+
it("must check that the focus is moved on the editor once the popup is deleted", async () => {
704+
await Promise.all(
705+
pages.map(async ([, page]) => {
706+
await switchToHighlight(page);
707+
708+
await highlightSpan(page, 1, "Abstract");
709+
const editorSelector = getEditorSelector(0);
710+
await editComment(page, editorSelector, "Hello world!");
711+
712+
await waitAndClick(
713+
page,
714+
`${editorSelector} button.annotationCommentButton`
715+
);
716+
717+
const popupSelector = "#commentPopup";
718+
await page.waitForSelector(popupSelector, { visible: true });
719+
const handle = await page.evaluateHandle(
720+
sel => [
721+
new Promise(resolve => {
722+
document
723+
.querySelector(sel)
724+
.addEventListener("focusin", resolve, {
725+
once: true,
726+
});
727+
}),
728+
],
729+
editorSelector
730+
);
731+
await waitAndClick(
732+
page,
733+
`${popupSelector} button.commentPopupDelete`
734+
);
735+
await awaitPromise(handle);
736+
})
737+
);
738+
});
702739
});
703740
});

web/comment_manager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,7 @@ class CommentPopup {
10481048
},
10491049
});
10501050
this.#editor.comment = null;
1051+
this.#editor.focus();
10511052
this.destroy();
10521053
});
10531054
del.addEventListener("contextmenu", noContextMenu);

0 commit comments

Comments
 (0)