aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--web_src/css/modules/checkbox.css2
-rw-r--r--web_src/js/modules/fomantic/checkbox.js17
2 files changed, 14 insertions, 5 deletions
diff --git a/web_src/css/modules/checkbox.css b/web_src/css/modules/checkbox.css
index fc44a7c115..9238e0b3f3 100644
--- a/web_src/css/modules/checkbox.css
+++ b/web_src/css/modules/checkbox.css
@@ -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 {
diff --git a/web_src/js/modules/fomantic/checkbox.js b/web_src/js/modules/fomantic/checkbox.js
index ffe853b28f..7f2b340296 100644
--- a/web_src/js/modules/fomantic/checkbox.js
+++ b/web_src/js/modules/fomantic/checkbox.js
@@ -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');
}
}