Merge pull request #17318 from calixteman/bug1864136_2
Make sure that only one radio button is checked in its group (bug 1864136)
This commit is contained in:
commit
d679078beb
@ -1637,6 +1637,21 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
||||
storage.setValue(id, { value });
|
||||
}
|
||||
|
||||
if (value) {
|
||||
// It's possible that multiple radio buttons are checked.
|
||||
// So if this one is checked we just reset the other ones.
|
||||
// (see bug 1864136). Then when the other ones will be rendered they will
|
||||
// unchecked (because of their value in the storage).
|
||||
// Consequently, the first checked radio button will be the only checked
|
||||
// one.
|
||||
for (const radio of this._getElementsByName(
|
||||
data.fieldName,
|
||||
/* skipId = */ id
|
||||
)) {
|
||||
storage.setValue(radio.id, { value: false });
|
||||
}
|
||||
}
|
||||
|
||||
const element = document.createElement("input");
|
||||
GetElementsByNameSet.add(element);
|
||||
element.setAttribute("data-element-id", id);
|
||||
|
@ -219,6 +219,8 @@ class Rasterize {
|
||||
outputScale,
|
||||
annotations,
|
||||
annotationCanvasMap,
|
||||
annotationStorage,
|
||||
fieldObjects,
|
||||
page,
|
||||
imageResourcesPath,
|
||||
renderForms = false
|
||||
@ -244,6 +246,8 @@ class Rasterize {
|
||||
linkService: new SimpleLinkService(),
|
||||
imageResourcesPath,
|
||||
renderForms,
|
||||
annotationStorage,
|
||||
fieldObjects,
|
||||
};
|
||||
|
||||
// Ensure that the annotationLayer gets translated.
|
||||
@ -682,6 +686,10 @@ class Driver {
|
||||
}
|
||||
}
|
||||
|
||||
if (task.forms) {
|
||||
task.fieldObjects = await doc.getFieldObjects();
|
||||
}
|
||||
|
||||
this._nextPage(task, failure);
|
||||
},
|
||||
err => {
|
||||
@ -928,9 +936,7 @@ class Driver {
|
||||
transform,
|
||||
};
|
||||
if (renderForms) {
|
||||
renderContext.annotationMode = task.annotationStorage
|
||||
? AnnotationMode.ENABLE_STORAGE
|
||||
: AnnotationMode.ENABLE_FORMS;
|
||||
renderContext.annotationMode = AnnotationMode.ENABLE_FORMS;
|
||||
} else if (renderPrint) {
|
||||
if (task.annotationStorage) {
|
||||
renderContext.annotationMode = AnnotationMode.ENABLE_STORAGE;
|
||||
@ -984,6 +990,8 @@ class Driver {
|
||||
outputScale,
|
||||
data,
|
||||
annotationCanvasMap,
|
||||
task.pdfDoc.annotationStorage,
|
||||
task.fieldObjects,
|
||||
page,
|
||||
IMAGE_RESOURCES_PATH,
|
||||
renderForms
|
||||
|
@ -2261,9 +2261,15 @@ describe("Interaction", () => {
|
||||
expect(storage)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual({
|
||||
"22R": { value: false },
|
||||
"25R": { value: true },
|
||||
"28R": { value: false },
|
||||
"35R": { value: false },
|
||||
"38R": { value: false },
|
||||
"41R": { value: false },
|
||||
"44R": { value: false },
|
||||
"47R": { value: false },
|
||||
"50R": { value: false },
|
||||
"22R": { value: false },
|
||||
});
|
||||
|
||||
await page.click(getSelector("22R"));
|
||||
@ -2273,9 +2279,15 @@ describe("Interaction", () => {
|
||||
expect(storage)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual({
|
||||
"22R": { value: true },
|
||||
"25R": { value: false },
|
||||
"28R": { value: false },
|
||||
"35R": { value: false },
|
||||
"38R": { value: false },
|
||||
"41R": { value: false },
|
||||
"44R": { value: false },
|
||||
"47R": { value: false },
|
||||
"50R": { value: false },
|
||||
"22R": { value: true },
|
||||
});
|
||||
})
|
||||
);
|
||||
|
2
test/pdfs/bug1864136.pdf.link
Normal file
2
test/pdfs/bug1864136.pdf.link
Normal file
@ -0,0 +1,2 @@
|
||||
https://bugzilla.mozilla.org/attachment.cgi?id=9363183
|
||||
|
@ -8361,5 +8361,16 @@
|
||||
"rotation": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bug1864136-forms",
|
||||
"file": "pdfs/bug1864136.pdf",
|
||||
"md5": "97357ad5b0fde2c4e79c07819e4d9710",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"firstPage": 2,
|
||||
"lastPage": 2,
|
||||
"type": "eq",
|
||||
"forms": true
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user