Skip to content

Commit

Permalink
Merge pull request #14027 from calixteman/14024
Browse files Browse the repository at this point in the history
Annotation - Checkboxes with the same name and export values must be in unison
  • Loading branch information
calixteman authored Sep 15, 2021
2 parents 7fb653b + a3aa6dd commit 8c2ac85
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,25 +976,29 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
const element = document.createElement("input");
element.disabled = data.readOnly;
element.type = "checkbox";
element.name = this.data.fieldName;
element.name = data.fieldName;
if (value) {
element.setAttribute("checked", true);
}
element.setAttribute("id", id);
element.setAttribute("exportValue", data.exportValue);
element.tabIndex = DEFAULT_TAB_INDEX;

element.addEventListener("change", function (event) {
const name = event.target.name;
const checked = event.target.checked;
for (const checkbox of document.getElementsByName(name)) {
if (checkbox !== event.target) {
checkbox.checked = false;
checkbox.checked =
checked &&
checkbox.getAttribute("exportValue") === data.exportValue;
storage.setValue(
checkbox.parentNode.getAttribute("data-annotation-id"),
{ value: false }
);
}
}
storage.setValue(id, { value: event.target.checked });
storage.setValue(id, { value: checked });
});

if (this.enableScripting && this.hasJSActions) {
Expand Down

0 comments on commit 8c2ac85

Please sign in to comment.