a11y(toggles): native Checkboxen als role=switch mit synchron gepflegtem aria-checked

This commit is contained in:
2026-06-13 21:00:59 +02:00
parent 02c36dba09
commit 3e93efb785
2 changed files with 13 additions and 7 deletions
+6
View File
@@ -166,6 +166,11 @@ function applySettings() {
const imgRefBtn = document.querySelector('[data-action="image-ref"]');
if (imgRefBtn) imgRefBtn.classList.toggle('hidden', !settings.imageRefEnabled);
// A11y: aria-checked aller role=switch-Toggles an den realen checked-State angleichen
document.querySelectorAll('.toggle input[role="switch"]').forEach(cb => {
cb.setAttribute('aria-checked', cb.checked ? 'true' : 'false');
});
// Toolbar-Position
document.body.classList.toggle('toolbar-left', settings.toolbarPos === 'left');
const toolbarPosEl = document.getElementById('settingToolbarPos');
@@ -250,6 +255,7 @@ function bindSettingsEvents() {
const el = document.getElementById(id);
if (el) {
el.addEventListener('change', async e => {
e.target.setAttribute('aria-checked', e.target.checked ? 'true' : 'false');
fn(e.target.checked);
await saveSettings();
});