[Editor] Add the possibility to unselect a comment from the sidebar

This commit is contained in:
Calixte Denizet 2025-10-01 14:36:12 +02:00
parent 042e821bec
commit bb556dcb5c
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 }) {
if (currentTarget.classList.contains("selected")) {
currentTarget.classList.remove("selected");
this.#popup._hide();
return;
}
const annotation = this.#elementsToAnnotations.get(currentTarget);