Skip to content

Commit

Permalink
[Editor] Make sure the save checkbox isn't focusable when saving is d…
Browse files Browse the repository at this point in the history
…isabled (bug 1952558)

And fix the the width of the warning message when the limit of signatures has been reached:
in french the string is longer than the dialog's one.
  • Loading branch information
calixteman committed Mar 10, 2025
1 parent 81baa16 commit 69a2e51
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
10 changes: 5 additions & 5 deletions test/integration/signature_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("Signature Editor", () => {
);
await page.click("#addSignatureTypeInput");
await page.waitForSelector(
"#addSignatureSaveContainer[disabled=true]"
"#addSignatureSaveContainer > input:disabled"
);
let description = await page.$eval(
descriptionInputSelector,
Expand All @@ -99,7 +99,7 @@ describe("Signature Editor", () => {

// The save button should be enabled now.
await page.waitForSelector(
"#addSignatureSaveContainer:not([disabled])"
"#addSignatureSaveContainer > input:not(:disabled)"
);
await page.waitForSelector("#addSignatureSaveCheckbox[checked=true]");

Expand All @@ -126,7 +126,7 @@ describe("Signature Editor", () => {
);
// The save button should be disabled now.
await page.waitForSelector(
"#addSignatureSaveContainer[disabled=true]"
"#addSignatureSaveContainer > input:disabled"
);
await page.waitForSelector(`${addButtonSelector}:disabled`);

Expand Down Expand Up @@ -249,7 +249,7 @@ describe("Signature Editor", () => {

// The save button should be enabled now.
await page.waitForSelector(
"#addSignatureSaveContainer:not([disabled])"
"#addSignatureSaveContainer > input:not(:disabled)"
);
await page.waitForSelector("#addSignatureSaveCheckbox[checked=true]");

Expand Down Expand Up @@ -305,7 +305,7 @@ describe("Signature Editor", () => {

// The save button should be enabled now.
await page.waitForSelector(
"#addSignatureSaveContainer:not([disabled])"
"#addSignatureSaveContainer > input:not(:disabled)"
);
await page.waitForSelector("#addSignatureSaveCheckbox[checked=true]");

Expand Down
14 changes: 5 additions & 9 deletions web/signature_manager.css
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,16 @@

#addSignatureSaveContainer {
display: grid;
grid-template-columns: max-content max-content;
grid-template-columns: max-content auto;
gap: 4px;
width: 100%;

> input {
margin: 0;

&:disabled + label {
opacity: 0.4;
}
}

> label {
Expand All @@ -617,14 +621,6 @@
color: var(--save-warning-color);
font-size: 11px;
}

&:is([disabled], .fullStorage) {
pointer-events: none;

> :not(#addSignatureSaveWarning) {
opacity: 0.4;
}
}
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions web/signature_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,10 @@ class SignatureManager {
}

#disableButtons(value) {
this.#clearButton.disabled = this.#addButton.disabled = !value;
if (value) {
this.#saveContainer.removeAttribute("disabled");
} else {
this.#saveContainer.setAttribute("disabled", true);
}
this.#saveCheckbox.disabled =
this.#clearButton.disabled =
this.#addButton.disabled =
!value;
}

#initTypeTab(reset) {
Expand Down
4 changes: 2 additions & 2 deletions web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@
<input id="addSignatureFilePicker" type="file"></input>
</div>
</div>
<div id="addSignatureControls" disabled>
<div id="addSignatureControls">
<div id="horizontalContainer">
<div id="addSignatureDescriptionContainer">
<label for="addSignatureDescription" data-l10n-id="pdfjs-editor-add-signature-description-label">Description (alt text)</span></label>
Expand All @@ -739,7 +739,7 @@
<button id="clearSignatureButton" type="button" data-l10n-id="pdfjs-editor-add-signature-clear-button" tabindex="0"><span data-l10n-id="pdfjs-editor-add-signature-clear-button-label">Clear signature</span></button>
</div>
<div id="addSignatureSaveContainer">
<input type="checkbox" id="addSignatureSaveCheckbox" checked="true" tabindex="0"></input>
<input type="checkbox" id="addSignatureSaveCheckbox" checked="true"></input>
<label for="addSignatureSaveCheckbox" data-l10n-id="pdfjs-editor-add-signature-save-checkbox">Save signature</label>
<span></span>
<span id="addSignatureSaveWarning" data-l10n-id="pdfjs-editor-add-signature-save-warning-message">You’ve reached the limit of 5 saved signatures. Remove one to save more.</span>
Expand Down

0 comments on commit 69a2e51

Please sign in to comment.