Merge pull request #20322 from calixteman/bug1990491

[Editor] Add the possibility to unselect a comment from the sidebar
This commit is contained in:
calixteman 2025-10-01 15:24:03 +02:00 committed by GitHub
commit 7fa50712c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View File

@ -594,5 +594,34 @@ describe("Comment", () => {
}) })
); );
}); });
it("must check that comments can be selected/unselected", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await switchToComment(page);
const firstElementSelector =
"#editorCommentsSidebarList li:first-child";
await waitAndClick(page, firstElementSelector);
const popupSelector = "#commentPopup";
await page.waitForSelector(popupSelector, { visible: true });
const popupTextSelector = `${popupSelector} .commentPopupText`;
await page.waitForSelector(popupTextSelector, {
visible: true,
});
const popupText = await page.evaluate(
selector => document.querySelector(selector).textContent,
popupTextSelector
);
expect(popupText)
.withContext(`In ${browserName}`)
.toEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
// Click again to unselect the comment.
await waitAndClick(page, firstElementSelector);
await page.waitForSelector(popupSelector, { visible: false });
})
);
});
}); });
}); });

View File

@ -575,6 +575,8 @@ class CommentSidebar {
async #commentClick({ currentTarget }) { async #commentClick({ currentTarget }) {
if (currentTarget.classList.contains("selected")) { if (currentTarget.classList.contains("selected")) {
currentTarget.classList.remove("selected");
this.#popup._hide();
return; return;
} }
const annotation = this.#elementsToAnnotations.get(currentTarget); const annotation = this.#elementsToAnnotations.get(currentTarget);