diff --git a/htdocs/js/RadioButtons/RadioButtons.js b/htdocs/js/RadioButtons/RadioButtons.js index 18f82279ce..8ca1333111 100644 --- a/htdocs/js/RadioButtons/RadioButtons.js +++ b/htdocs/js/RadioButtons/RadioButtons.js @@ -15,23 +15,33 @@ 'use strict'; (() => { + const radioGroups = {}; + // Setup uncheckable radios. const setupUncheckableRadio = (radio) => { if (!radio.dataset.uncheckableRadioButton) return; delete radio.dataset.uncheckableRadioButton; + if (!radioGroups[radio.name]) radioGroups[radio.name] = [radio]; + else radioGroups[radio.name].push(radio); + if (radio.checked) radio.dataset.currentlyChecked = '1'; radio.addEventListener('click', (e) => { if (radio.dataset.shift && !e.shiftKey) { + for (const groupRadio of radioGroups[radio.name]) { + delete groupRadio.dataset.currentlyChecked; + } radio.dataset.currentlyChecked = '1'; return; } - const currentlyChecked = radio.dataset.currentlyChecked; - if (currentlyChecked) { + if (radio.dataset.currentlyChecked) { delete radio.dataset.currentlyChecked; radio.checked = false; } else { + for (const groupRadio of radioGroups[radio.name]) { + delete groupRadio.dataset.currentlyChecked; + } radio.dataset.currentlyChecked = '1'; } });