diff --git a/components/interactive-elements.html b/components/interactive-elements.html index 2155b36..74587a9 100644 --- a/components/interactive-elements.html +++ b/components/interactive-elements.html @@ -676,9 +676,11 @@ return; } - options.forEach((option, index) => { - option.setAttribute('aria-checked', String(isActive && index === 0)); - }); + if (!isActive) { + options.forEach((option) => { + option.setAttribute('aria-checked', 'false'); + }); + } target.dataset.open = 'false'; trigger.setAttribute('aria-expanded', 'false'); updatePulldownSelectionState(target); @@ -691,17 +693,22 @@ return; } - checkbox.setAttribute('aria-checked', String(isActive)); - checkbox.classList.toggle('sg-form-active', isActive); + if (!isActive) { + checkbox.setAttribute('aria-checked', 'false'); + } + const isChecked = checkbox.getAttribute('aria-checked') === 'true'; + checkbox.classList.toggle('sg-form-active', isChecked); checkbox.classList.toggle('sg-checkbox-field--inactive-selectable', !isActive); return; } if (componentType === 'radio-field') { const radios = target.querySelectorAll('.sg-radio-field'); - const defaultRadio = radios[0]; radios.forEach((radio) => { - const checked = isActive && radio === defaultRadio; + if (!isActive) { + radio.setAttribute('aria-checked', 'false'); + } + const checked = radio.getAttribute('aria-checked') === 'true'; radio.setAttribute('aria-checked', String(checked)); radio.classList.toggle('sg-form-active', checked); radio.classList.toggle('sg-radio-field--inactive-selectable', !isActive);