mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-11-30 16:37:18 +01:00
Merge pull request #22554 from ohall-m/bug-2084998-signature-description
Bug 2084998 - Improve the presentation of signature elements that no longer have an edit toolbar
This commit is contained in:
@@ -166,6 +166,7 @@ class SignatureEditor extends DrawingEditor {
|
||||
}
|
||||
|
||||
super.render();
|
||||
this.#updateRoleForSelection();
|
||||
|
||||
if (this._drawId === null) {
|
||||
if (this.#signatureData) {
|
||||
@@ -216,6 +217,27 @@ class SignatureEditor extends DrawingEditor {
|
||||
return this.div;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
select() {
|
||||
super.select();
|
||||
this.#updateRoleForSelection();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
unselect() {
|
||||
super.unselect();
|
||||
this.#updateRoleForSelection();
|
||||
}
|
||||
|
||||
#updateRoleForSelection() {
|
||||
if (this._uiManager._useButtonRoleForUnselectedSignatures) {
|
||||
this.div?.setAttribute(
|
||||
"role",
|
||||
this.isSelected ? "application" : "button"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setUuid(uuid) {
|
||||
this.#signatureUUID = uuid;
|
||||
this.addEditToolbar();
|
||||
|
||||
@@ -998,7 +998,8 @@ class AnnotationEditorUIManager {
|
||||
mlManager,
|
||||
editorUndoBar,
|
||||
supportsPinchToZoom,
|
||||
keepToolbarInPage
|
||||
keepToolbarInPage,
|
||||
useButtonRoleForUnselectedSignatures
|
||||
) {
|
||||
const signal = (this._signal = this.#abortController.signal);
|
||||
this.#container = container;
|
||||
@@ -1062,6 +1063,8 @@ class AnnotationEditorUIManager {
|
||||
this._editorUndoBar = editorUndoBar || null;
|
||||
this._supportsPinchToZoom = supportsPinchToZoom !== false;
|
||||
this._keepToolbarInPage = keepToolbarInPage === true;
|
||||
this._useButtonRoleForUnselectedSignatures =
|
||||
useButtonRoleForUnselectedSignatures === true;
|
||||
commentManager?.setSidebarUiManager(this);
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
getRect,
|
||||
getSerialized,
|
||||
isCanvasMonochrome,
|
||||
selectEditor,
|
||||
unselectEditor,
|
||||
waitForAnnotationEditorLayer,
|
||||
waitForNoElement,
|
||||
waitForPageRendered,
|
||||
@@ -263,6 +265,54 @@ describe("GeckoView viewer", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("must expose an unselected signature as a button", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([, page]) => {
|
||||
await addSignature(page, "Hello");
|
||||
const editorSelector = getEditorSelector(0);
|
||||
await waitForSelectedEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="application"]`);
|
||||
|
||||
await unselectEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="button"]`);
|
||||
await page.waitForSelector(`${editorSelector} .editToolbar.hidden`);
|
||||
|
||||
await selectEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="application"]`);
|
||||
await page.waitForSelector(
|
||||
`${editorSelector} .editToolbar:not(.hidden)`
|
||||
);
|
||||
|
||||
await unselectEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="button"]`);
|
||||
await page.focus(editorSelector);
|
||||
await waitForSelectedEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="application"]`);
|
||||
await page.waitForSelector(
|
||||
`${editorSelector} .editToolbar:not(.hidden)`
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("must expose the previous signature as a button when adding another one", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([, page]) => {
|
||||
await addSignature(page, "Hello");
|
||||
const editorSelector = getEditorSelector(0);
|
||||
await waitForSelectedEditor(page, editorSelector);
|
||||
|
||||
await addSignature(page, "World");
|
||||
const secondEditorSelector = getEditorSelector(1);
|
||||
await waitForSelectedEditor(page, secondEditorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="button"]`);
|
||||
await page.waitForSelector(
|
||||
`${secondEditorSelector}[role="application"]`
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("must ignore a signature without any text", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
|
||||
@@ -26,8 +26,11 @@ import {
|
||||
loadAndWait,
|
||||
paste,
|
||||
PDI,
|
||||
selectEditor,
|
||||
switchToEditor,
|
||||
unselectEditor,
|
||||
waitForPointerUp,
|
||||
waitForSelectedEditor,
|
||||
waitForTextToBe,
|
||||
waitForTimeout,
|
||||
} from "./test_utils.mjs";
|
||||
@@ -230,6 +233,34 @@ describe("Signature Editor", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("must keep the application role for an unselected signature", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([_, page]) => {
|
||||
await switchToSignature(page);
|
||||
await page.click("#editorSignatureAddSignature");
|
||||
await page.waitForSelector("#addSignatureDialog", {
|
||||
visible: true,
|
||||
});
|
||||
await page.type("#addSignatureTypeInput", "PDF.js");
|
||||
await page.waitForSelector(`${addButtonSelector}:not(:disabled)`);
|
||||
await page.click(addButtonSelector);
|
||||
await page.waitForSelector("#addSignatureDialog", {
|
||||
visible: false,
|
||||
});
|
||||
|
||||
const editorSelector = getEditorSelector(0);
|
||||
await waitForSelectedEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="application"]`);
|
||||
|
||||
await unselectEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="application"]`);
|
||||
|
||||
await selectEditor(page, editorSelector);
|
||||
await page.waitForSelector(`${editorSelector}[role="application"]`);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("must check drawing with the mouse", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
|
||||
@@ -1025,6 +1025,10 @@ class PDFViewer {
|
||||
this.#editorUndoBar,
|
||||
this.#supportsPinchToZoom,
|
||||
// GeckoView's toolbar sticks out of the editor.
|
||||
typeof PDFJSDev === "undefined"
|
||||
? window.isGECKOVIEW
|
||||
: PDFJSDev.test("GECKOVIEW"),
|
||||
// GeckoView needs unselected signatures as buttons for TalkBack.
|
||||
typeof PDFJSDev === "undefined"
|
||||
? window.isGECKOVIEW
|
||||
: PDFJSDev.test("GECKOVIEW")
|
||||
|
||||
Reference in New Issue
Block a user