Skip to content

[Editor] Set an aria-description for an added signature (bug 1956513) #19728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions l10n/en-US/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,13 @@ pdfjs-editor-highlight-editor =
# “Drawing” is a noun, the string is used on the editor for drawings.
pdfjs-editor-ink-editor =
.aria-label = Drawing editor
pdfjs-editor-signature-editor =
.aria-label = Signature editor

# Used when a signature editor is selected/hovered.
# Variables:
# $description (String) - a string describing/labeling the signature.
pdfjs-editor-signature-editor1 =
.aria-description = Signature editor: { $description }

pdfjs-editor-stamp-editor =
.aria-label = Image editor

Expand Down
17 changes: 15 additions & 2 deletions src/display/editor/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class SignatureEditor extends DrawingEditor {
this._willKeepAspectRatio = true;
this.#signatureData = params.signatureData || null;
this.#description = null;
this.defaultL10nId = "pdfjs-editor-signature-editor";
this.defaultL10nId = "pdfjs-editor-signature-editor1";
}

/** @inheritdoc */
Expand Down Expand Up @@ -158,6 +158,13 @@ class SignatureEditor extends DrawingEditor {

super.render();

if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
// TODO: remove this check once
// https://github.com/projectfluent/fluent.js/pull/640
// is merged and released.
this.div.setAttribute("data-l10n-attrs", "aria-description");
}

if (this._drawId === null) {
if (this.#signatureData) {
const {
Expand All @@ -183,6 +190,12 @@ class SignatureEditor extends DrawingEditor {
});
this.addSignature(outline, heightInPage, description, uuid);
} else {
// Avoid Firefox crashing (with a local build) because the description
// parameter is missing.
this.div.setAttribute(
"data-l10n-args",
JSON.stringify({ description: "" })
);
this.div.hidden = true;
this._uiManager.getSignature(this);
}
Expand Down Expand Up @@ -259,7 +272,7 @@ class SignatureEditor extends DrawingEditor {
const { outline } = (this.#signatureData = data);
this.#isExtracted = outline instanceof ContourDrawOutline;
this.#description = description;
this.div.setAttribute("aria-description", description);
this.div.setAttribute("data-l10n-args", JSON.stringify({ description }));
let drawingOptions;
if (this.#isExtracted) {
drawingOptions = SignatureEditor.getDefaultDrawingOptions();
Expand Down
4 changes: 2 additions & 2 deletions test/integration/signature_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ describe("Signature Editor", () => {
`.altText.editDescription[title="Hello World"]`
);

// Check the aria label.
// Check the aria description.
await page.waitForSelector(
`${editorSelector}[aria-description="Hello World"]`
`${editorSelector}[aria-description="Signature editor: \u2068Hello World\u2069"]`
);

// Edit the description.
Expand Down