[Editor] Let the Save button always enabled in the alt-text dialog

This commit is contained in:
Calixte Denizet 2023-09-22 19:35:01 +02:00
parent f66613c8e4
commit d5936d9a15
3 changed files with 5 additions and 13 deletions

View File

@ -932,6 +932,9 @@ class AnnotationEditor {
}
set altTextData({ altText, decorative }) {
if (this.#altText === altText && this.#altTextDecorative === decorative) {
return;
}
this.#altText = altText;
this.#altTextDecorative = decorative;
this.#setAltTextButtonState();

View File

@ -52,8 +52,6 @@ class AltTextManager {
#container;
#previousDecorative = null;
constructor(
{
dialog,
@ -82,7 +80,6 @@ class AltTextManager {
saveButton.addEventListener("click", this.#save.bind(this));
optionDescription.addEventListener("change", this.#boundUpdateUIState);
optionDecorative.addEventListener("change", this.#boundUpdateUIState);
textarea.addEventListener("input", this.#boundUpdateUIState);
this.#overlayManager.register(dialog);
}
@ -151,7 +148,6 @@ class AltTextManager {
this.#optionDescription.checked = true;
}
this.#previousAltText = this.#textarea.value = altText?.trim() || "";
this.#previousDecorative = decorative;
this.#updateUIState();
this.#currentEditor = editor;
@ -268,14 +264,7 @@ class AltTextManager {
}
#updateUIState() {
const altText = this.#textarea.value.trim();
const decorative = this.#optionDecorative.checked;
this.#textarea.disabled = decorative;
this.#saveButton.disabled = !(
this.#previousDecorative !== decorative ||
this.#previousAltText !== altText
);
this.#textarea.disabled = this.#optionDecorative.checked;
}
#save() {

View File

@ -522,7 +522,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
<div id="buttons">
<button id="altTextCancel" tabindex="0"><span data-l10n-id="editor_alt_text_cancel_button">Cancel</span></button>
<button id="altTextSave" tabindex="0" disabled><span data-l10n-id="editor_alt_text_save_button">Save</span></button>
<button id="altTextSave" tabindex="0"><span data-l10n-id="editor_alt_text_save_button">Save</span></button>
</div>
</div>
</dialog>