Merge pull request #16864 from calixteman/issue16863

Don't reset all fields when the resetForm argument is an array
This commit is contained in:
calixteman 2023-08-24 09:56:11 -04:00 committed by GitHub
commit 62a294bb52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 6 deletions

View File

@ -3190,6 +3190,9 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
this._streams.push(this.uncheckedAppearance);
}
this._fallbackFontDict = this.fallbackFontDict;
if (this.data.defaultFieldValue === null) {
this.data.defaultFieldValue = "Off";
}
}
_processRadioButton(params) {
@ -3238,6 +3241,9 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
this._streams.push(this.uncheckedAppearance);
}
this._fallbackFontDict = this.fallbackFontDict;
if (this.data.defaultFieldValue === null) {
this.data.defaultFieldValue = "Off";
}
}
_processPushButton(params) {

View File

@ -373,11 +373,7 @@ class AnnotationElement {
event.target.title = event.detail.userName;
},
readonly: event => {
if (event.detail.readonly) {
event.target.setAttribute("readonly", "");
} else {
event.target.removeAttribute("readonly");
}
event.target.disabled = event.detail.readonly;
},
required: event => {
this._setRequired(event.target, event.detail.required);

View File

@ -1185,7 +1185,7 @@ class Doc extends PDFObject {
resetForm(aFields = null) {
// Handle the case resetForm({ aFields: ... })
if (aFields && typeof aFields === "object") {
if (aFields && typeof aFields === "object" && !Array.isArray(aFields)) {
aFields = aFields.aFields;
}

View File

@ -2098,4 +2098,60 @@ describe("Interaction", () => {
);
});
});
describe("in issue16863.pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue16863.pdf", getSelector("334R"));
});
afterAll(async () => {
await closePages(pages);
});
it("must check that checkboxes are correctly resetted", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);
let readonly = await page.$eval(
getSelector("353R"),
el => el.disabled
);
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
await page.click(getSelector("334R"));
await page.waitForTimeout(10);
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
await page.click(getSelector("351R"));
await page.waitForTimeout(10);
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
await page.click(getSelector("352R"));
await page.waitForTimeout(10);
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
expect(readonly).withContext(`In ${browserName}`).toEqual(false);
await page.click(getSelector("353R"));
await page.waitForTimeout(10);
let checked = await page.$eval(getSelector("353R"), el => el.checked);
expect(checked).withContext(`In ${browserName}`).toEqual(true);
await page.click(getSelector("334R"));
await page.waitForTimeout(10);
readonly = await page.$eval(getSelector("353R"), el => el.disabled);
expect(readonly).withContext(`In ${browserName}`).toEqual(true);
checked = await page.$eval(getSelector("353R"), el => el.checked);
expect(checked).withContext(`In ${browserName}`).toEqual(false);
})
);
});
});
});

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/12422360/4422-84.pdf

View File

@ -8119,5 +8119,12 @@
"rotation": 0
}
}
},
{
"id": "issue16863",
"file": "pdfs/issue16863.pdf",
"md5": "af8abe281721f92a0d46646969f061de",
"link": true,
"type": "other"
}
]