mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Fix clicking on radio buttons (and improve code) (#18078)
This commit is contained in:
parent
c5ba74e0b4
commit
292cdc7621
@ -7,22 +7,25 @@ import { fireEvent } from "../common/dom/fire_event";
|
|||||||
@customElement("ha-formfield")
|
@customElement("ha-formfield")
|
||||||
export class HaFormfield extends FormfieldBase {
|
export class HaFormfield extends FormfieldBase {
|
||||||
protected _labelClick() {
|
protected _labelClick() {
|
||||||
const input = this.input;
|
const input = this.input as HTMLInputElement | undefined;
|
||||||
if (input) {
|
if (!input) return;
|
||||||
input.focus();
|
|
||||||
switch (input.tagName) {
|
input.focus();
|
||||||
case "HA-CHECKBOX":
|
if (input.disabled) {
|
||||||
case "HA-RADIO":
|
return;
|
||||||
if ((input as any).disabled) {
|
}
|
||||||
break;
|
switch (input.tagName) {
|
||||||
}
|
case "HA-CHECKBOX":
|
||||||
(input as any).checked = !(input as any).checked;
|
input.checked = !input.checked;
|
||||||
fireEvent(input, "change");
|
fireEvent(input, "change");
|
||||||
break;
|
break;
|
||||||
default:
|
case "HA-RADIO":
|
||||||
input.click();
|
input.checked = true;
|
||||||
break;
|
fireEvent(input, "change");
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
input.click();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user