Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web_src/css/modules/checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ input[type="radio"] {

.ui.checkbox label,
.ui.radio.checkbox label {
padding-left: 1.85714em;
margin-left: 1.85714em;
}

.ui.checkbox + label {
Expand Down
17 changes: 13 additions & 4 deletions web_src/js/modules/fomantic/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ export function initAriaCheckboxPatch() {
if (el.hasAttribute('data-checkbox-patched')) continue;
const label = el.querySelector('label');
const input = el.querySelector('input');
if (!label || !input || input.getAttribute('id') || label.getAttribute('for')) continue;
const id = generateAriaId();
input.setAttribute('id', id);
label.setAttribute('for', id);
if (!label || !input) continue;
const inputId = input.getAttribute('id');
const labelFor = label.getAttribute('for');

if (inputId && !labelFor) { // missing "for"
label.setAttribute('for', inputId);
} else if (!inputId && !labelFor) { // missing both "id" and "for"
const id = generateAriaId();
input.setAttribute('id', id);
label.setAttribute('for', id);
} else {
continue;
}
el.setAttribute('data-checkbox-patched', 'true');
}
}