Merge pull request #12707 from calixteman/radio_check

Checkboxes with the same name must behave like a radio buttons group
This commit is contained in:
Tim van der Meij 2020-12-09 23:29:03 +01:00 committed by GitHub
commit f48cfba945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -717,6 +717,16 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
}
element.addEventListener("change", function (event) {
const name = event.target.name;
for (const checkbox of document.getElementsByName(name)) {
if (checkbox !== event.target) {
checkbox.checked = false;
storage.setValue(
checkbox.parentNode.getAttribute("data-annotation-id"),
{ value: false }
);
}
}
storage.setValue(id, { value: event.target.checked });
});