Skip to content

Commit b4abd98

Browse files
Refine interactive checkbox logic per review feedback
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
1 parent b6e9355 commit b4abd98

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

docs/step.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,16 @@
183183
}
184184

185185
checkboxes.forEach((checkbox, index) => {
186-
checkbox.removeAttribute('disabled');
187186
checkbox.disabled = false;
188-
checkbox.checked = checkedIndexes.includes(index) ? true : checkbox.checked;
187+
checkbox.checked = checkedIndexes.includes(index) || checkbox.checked;
189188
checkbox.setAttribute('aria-label', `Checklist item ${index + 1}`);
190189

191190
checkbox.addEventListener('change', () => {
192191
const updated = Array.from(checkboxes)
193-
.flatMap((cb, i) => (cb.checked ? [i] : []));
192+
.reduce((acc, cb, i) => {
193+
if (cb.checked) acc.push(i);
194+
return acc;
195+
}, []);
194196
localStorage.setItem(storageKey, JSON.stringify(updated));
195197
});
196198
});

0 commit comments

Comments
 (0)