Skip to content

Commit 5d6c41c

Browse files
authored
Merge pull request jdorn#696 from stroebjo/fix/checkbox_with_ids
fix: checkbox/label should have unqiue id/for attribues for clickable label
2 parents bd898be + a3a6152 commit 5d6c41c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/editors/checkbox.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ export class CheckboxEditor extends AbstractEditor {
2727

2828
build () {
2929
this.label = this.header = this.theme.getCheckboxLabel(this.getTitle(), this.isRequired())
30+
this.label.htmlFor = this.formname
31+
3032
if (this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description)
3133
if (this.options.infoText && !this.options.compact) this.infoButton = this.theme.getInfoButton(this.options.infoText)
3234
if (this.options.compact) this.container.classList.add('compact')
3335

3436
this.input = this.theme.getCheckbox()
37+
this.input.id = this.formname
3538
this.control = this.theme.getFormControl(this.label, this.input, this.description, this.infoButton)
3639

3740
if (this.schema.readOnly || this.schema.readonly) {

src/editors/multiselect.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ export class MultiSelectEditor extends AbstractEditor {
6161
this.inputs = {}
6262
this.controls = {}
6363
for (i = 0; i < this.option_keys.length; i++) {
64+
const id = this.formname + i.toString()
6465
this.inputs[this.option_keys[i]] = this.theme.getCheckbox()
66+
this.inputs[this.option_keys[i]].id = id
6567
this.select_options[this.option_keys[i]] = this.inputs[this.option_keys[i]]
6668
const label = this.theme.getCheckboxLabel(this.option_titles[i])
69+
label.htmlFor = id
6770
this.controls[this.option_keys[i]] = this.theme.getFormControl(label, this.inputs[this.option_keys[i]])
6871
}
6972

0 commit comments

Comments
 (0)