mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +00:00
Fix formfield label touch (#10867)
This commit is contained in:
parent
bfb84a834f
commit
2890192c05
@ -1,10 +1,28 @@
|
|||||||
import { Formfield } from "@material/mwc-formfield";
|
import { Formfield } from "@material/mwc-formfield";
|
||||||
import { css, CSSResultGroup } from "lit";
|
import { css, CSSResultGroup } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
|
|
||||||
@customElement("ha-formfield")
|
@customElement("ha-formfield")
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
export class HaFormfield extends Formfield {
|
export class HaFormfield extends Formfield {
|
||||||
|
protected _labelClick() {
|
||||||
|
const input = this.input;
|
||||||
|
if (input) {
|
||||||
|
input.focus();
|
||||||
|
switch (input.tagName) {
|
||||||
|
case "HA-CHECKBOX":
|
||||||
|
case "HA-RADIO":
|
||||||
|
(input as any).checked = !(input as any).checked;
|
||||||
|
fireEvent(input, "change");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
input.click();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static get styles(): CSSResultGroup {
|
protected static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
Formfield.styles,
|
Formfield.styles,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user