Skip to content

Commit 37c79c3

Browse files
authored
Merge pull request #20305 from calixteman/bug1990813
[Editor] Add a title to the comment buttons (bug 1990813)
2 parents 007148e + 90e56b7 commit 37c79c3

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

l10n/en-US/viewer.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ pdfjs-editor-edit-signature-update-button = Update
673673
674674
## Comment popup
675675

676+
pdfjs-show-comment-button =
677+
.title = Show comment
678+
676679
pdfjs-editor-edit-comment-popup-button-label = Edit comment
677680
pdfjs-editor-edit-comment-popup-button =
678681
.title = Edit comment

src/display/annotation_layer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,7 @@ class PopupElement {
24862486
button.tabIndex = 0;
24872487
button.ariaHasPopup = "dialog";
24882488
button.ariaControls = "commentPopup";
2489+
button.setAttribute("data-l10n-id", "pdfjs-show-comment-button");
24892490

24902491
const { signal } = (this.#popupAbortController = new AbortController());
24912492
button.addEventListener("keydown", this.#boundKeyDown, { signal });

src/display/editor/comment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class Comment {
143143

144144
if (isStandalone) {
145145
comment.ariaControls = "commentPopup";
146+
comment.setAttribute("data-l10n-id", "pdfjs-show-comment-button");
146147
} else {
147148
comment.ariaControlsElements = [
148149
this.#editor._uiManager.getCommentDialogElement(),

test/integration/comment_spec.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,69 @@ describe("Comment", () => {
238238
});
239239
});
240240

241+
describe("Comment buttons", () => {
242+
let pages;
243+
244+
beforeEach(async () => {
245+
pages = await loadAndWait(
246+
"tracemonkey.pdf",
247+
".annotationEditorLayer",
248+
"page-width",
249+
null,
250+
{ enableComment: true }
251+
);
252+
});
253+
254+
afterEach(async () => {
255+
await closePages(pages);
256+
});
257+
258+
it("must check that the comment button has a title", async () => {
259+
await Promise.all(
260+
pages.map(async ([browserName, page]) => {
261+
await switchToHighlight(page);
262+
263+
const rect = await getSpanRectFromText(page, 1, "Languages");
264+
const x = rect.x + rect.width / 2;
265+
const y = rect.y + rect.height / 2;
266+
await page.mouse.click(x, y, { count: 2, delay: 100 });
267+
await page.waitForSelector(getEditorSelector(0));
268+
269+
let commentButtonSelector = `${getEditorSelector(0)} button.comment`;
270+
await page.waitForSelector(commentButtonSelector, { visible: true });
271+
let title = await page.evaluate(
272+
selector => document.querySelector(selector).title,
273+
commentButtonSelector
274+
);
275+
expect(title)
276+
.withContext(`In ${browserName}`)
277+
.toEqual("Edit comment");
278+
await page.click(commentButtonSelector);
279+
280+
const textInputSelector = "#commentManagerTextInput";
281+
await page.waitForSelector(textInputSelector, {
282+
visible: true,
283+
});
284+
await page.type(textInputSelector, "Hello world!");
285+
286+
await page.click("#commentManagerSaveButton");
287+
288+
commentButtonSelector = `${getEditorSelector(0)} button.annotationCommentButton`;
289+
await page.waitForSelector(commentButtonSelector, {
290+
visible: true,
291+
});
292+
title = await page.evaluate(selector => {
293+
const button = document.querySelector(selector);
294+
return button.title;
295+
}, commentButtonSelector);
296+
expect(title)
297+
.withContext(`In ${browserName}`)
298+
.toEqual("Show comment");
299+
})
300+
);
301+
});
302+
});
303+
241304
describe("Comment sidebar", () => {
242305
let pages;
243306

0 commit comments

Comments
 (0)