Skip to content

Commit

Permalink
fix checkbox aria
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Jan 25, 2023
1 parent a31fedd commit ae3268c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions web_src/js/features/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,15 @@ function attachOneDropdownAria($dropdown) {
export function attachDropdownAria($dropdowns) {
$dropdowns.each((_, e) => attachOneDropdownAria($(e)));
}

export function attachCheckboxAria($checkboxes) {
$checkboxes.checkbox();
for (const el of $checkboxes) {
const label = el.querySelector('label');
const input = el.querySelector('input');
if (!label || !input || input.getAttribute('id')) continue;
const id = generateAriaId();
input.setAttribute('id', id);
label.setAttribute('for', id);
}
}
4 changes: 2 additions & 2 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {mqBinarySearch} from '../utils.js';
import {createDropzone} from './dropzone.js';
import {initCompColorPicker} from './comp/ColorPicker.js';
import {showGlobalErrorMessage} from '../bootstrap.js';
import {attachDropdownAria} from './aria.js';
import {attachCheckboxAria, attachDropdownAria} from './aria.js';
import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.js';
import {initTooltip} from '../modules/tippy.js';
import {svg} from '../svg.js';
Expand Down Expand Up @@ -111,7 +111,7 @@ export function initGlobalCommon() {
});
attachDropdownAria($uiDropdowns);

$('.ui.checkbox').checkbox();
attachCheckboxAria($('.ui.checkbox'));

$('.tabular.menu .item').tab();
$('.tabable.menu .item').tab();
Expand Down

0 comments on commit ae3268c

Please sign in to comment.