Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
[JS] Send a Validate action on change on Choice widget
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Feb 19, 2023
1 parent 255e982 commit dca54c8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1765,8 +1765,9 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
["mouseleave", "Mouse Exit"],
["mouseup", "Mouse Up"],
["input", "Action"],
["input", "Validate"],
],
event => event.target.checked
event => event.target.value
);
} else {
selectElement.addEventListener("input", function (event) {
Expand Down
39 changes: 39 additions & 0 deletions test/integration/scripting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1854,4 +1854,43 @@ describe("Interaction", () => {
);
});
});

describe("in issue16067.pdf", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait("issue16067.pdf", getSelector("6R"));
});

afterAll(async () => {
await closePages(pages);
});

it("must check that a field has the correct value when a choice is changed", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);

let text = await page.$eval(getSelector("44R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("");

await page.select(getSelector("6R"), "Yes");
await page.waitForTimeout(10);

text = await page.$eval(getSelector("44R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("Yes");

await clearInput(page, getSelector("44R"));

await page.select(getSelector("6R"), "No");
await page.waitForTimeout(10);

text = await page.$eval(getSelector("44R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("No");
})
);
});
});
});
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,4 @@
!issue16021.pdf
!bug1770750.pdf
!issue16063.pdf
!issue16067.pdf
Binary file added test/pdfs/issue16067.pdf
Binary file not shown.

0 comments on commit dca54c8

Please sign in to comment.