Skip to content

Commit a3a6152

Browse files
committed
fix: checkbox/label should have unqiue id/for attribues for clickable label
At least in case of the Bootstrap 4 theme the checkbox `<input>` is *not* nested under the `<label>`. So for the label to trigger the checkbox we need to connect those with an ID.
1 parent a7f1b9b commit a3a6152

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
@@ -29,11 +29,14 @@ export class CheckboxEditor extends AbstractEditor {
2929
build () {
3030
const self = this
3131
this.label = this.header = this.theme.getCheckboxLabel(this.getTitle(), this.isRequired())
32+
this.label.htmlFor = this.formname
33+
3234
if (this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description)
3335
if (this.options.infoText && !this.options.compact) this.infoButton = this.theme.getInfoButton(this.options.infoText)
3436
if (this.options.compact) this.container.classList.add('compact')
3537

3638
this.input = this.theme.getCheckbox()
39+
this.input.id = this.formname
3740
this.control = this.theme.getFormControl(this.label, this.input, this.description, this.infoButton)
3841

3942
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
@@ -65,9 +65,12 @@ export class MultiSelectEditor extends AbstractEditor {
6565
this.inputs = {}
6666
this.controls = {}
6767
for (i = 0; i < this.option_keys.length; i++) {
68+
const id = this.formname + i.toString()
6869
this.inputs[this.option_keys[i]] = this.theme.getCheckbox()
70+
this.inputs[this.option_keys[i]].id = id
6971
this.select_options[this.option_keys[i]] = this.inputs[this.option_keys[i]]
7072
const label = this.theme.getCheckboxLabel(this.option_titles[i])
73+
label.htmlFor = id
7174
this.controls[this.option_keys[i]] = this.theme.getFormControl(label, this.inputs[this.option_keys[i]])
7275
}
7376

0 commit comments

Comments
 (0)