mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
fix(a11y): associate labels to inputs in CardEditModal via for/id
Each label now has a for attribute pointing to a unique generated id on the corresponding input or textarea, satisfying WCAG 1.3.1. https://claude.ai/code/session_012cK5rUGQvqkuxUZ59x7dLn
This commit is contained in:
parent
f9c5ca0781
commit
7045d82eae
1 changed files with 6 additions and 4 deletions
10
src/modal.ts
10
src/modal.ts
|
|
@ -82,17 +82,19 @@ export class CardEditModal extends Modal {
|
|||
}
|
||||
|
||||
createLabeledInput(parent: HTMLElement, label: string, value: string) {
|
||||
const id = `pr-modal-${Math.random().toString(36).slice(2)}`;
|
||||
const wrapper = parent.createDiv({ cls: 'parallel-reader-modal-field' });
|
||||
wrapper.createEl('label', { text: label });
|
||||
const input = wrapper.createEl('input', { attr: { type: 'text' } });
|
||||
wrapper.createEl('label', { text: label, attr: { for: id } });
|
||||
const input = wrapper.createEl('input', { attr: { type: 'text', id } });
|
||||
input.value = value;
|
||||
return input;
|
||||
}
|
||||
|
||||
createLabeledTextarea(parent: HTMLElement, label: string, value: string, rows: number) {
|
||||
const id = `pr-modal-${Math.random().toString(36).slice(2)}`;
|
||||
const wrapper = parent.createDiv({ cls: 'parallel-reader-modal-field' });
|
||||
wrapper.createEl('label', { text: label });
|
||||
const textarea = wrapper.createEl('textarea');
|
||||
wrapper.createEl('label', { text: label, attr: { for: id } });
|
||||
const textarea = wrapper.createEl('textarea', { attr: { id } });
|
||||
textarea.rows = rows;
|
||||
textarea.value = value;
|
||||
return textarea;
|
||||
|
|
|
|||
Loading…
Reference in a new issue