Skip to content

Commit

Permalink
Merge pull request #17999 from calixteman/issue17998
Browse files Browse the repository at this point in the history
Set correctly the change property for the event triggered when a choice list is changed
  • Loading branch information
calixteman authored Apr 24, 2024
2 parents bda98b9 + 5580823 commit dafc4f6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {

selectElement.addEventListener("input", event => {
const exportValue = getValue(/* isExport */ true);
const change = getValue(/* isExport */ false);
storage.setValue(id, { value: exportValue });

event.preventDefault();
Expand All @@ -2003,6 +2004,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
id,
name: "Keystroke",
value: selectedValues,
change,
changeEx: exportValue,
willCommit: false,
commitKey: 1,
Expand Down
43 changes: 43 additions & 0 deletions test/integration/scripting_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2425,4 +2425,47 @@ describe("Interaction", () => {
);
});
});

describe("Value of event.change when a choice list is modified", () => {
let pages;
let otherPages;

beforeAll(async () => {
otherPages = await Promise.all(
global.integrationSessions.map(async session =>
session.browser.newPage()
)
);
pages = await loadAndWait("issue17998.pdf", getSelector("7R"));
});

afterAll(async () => {
await closePages(pages);
await Promise.all(otherPages.map(page => page.close()));
});

it("must check the properties of the event", async () => {
await Promise.all(
pages.map(async ([browserName, page], i) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);

for (const [value, expected] of [
["b", "change=B,changeEx=b,value=A"],
["c", "change=C,changeEx=c,value=B"],
["a", "change=A,changeEx=a,value=C"],
]) {
await page.select(getSelector("7R"), value);
await page.waitForFunction(
`${getQuerySelector("10R")}.value !== ""`
);
const text = await page.$eval(getSelector("10R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual(expected);
await clearInput(page, getSelector("10R"));
}
})
);
});
});
});
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -644,3 +644,4 @@
!issue17929.pdf
!issue12213.pdf
!tracemonkey_freetext.pdf
!issue17998.pdf
Binary file added test/pdfs/issue17998.pdf
Binary file not shown.

0 comments on commit dafc4f6

Please sign in to comment.