From 2890192c054fdb48fe5d2181d73ef94900ee7fc7 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 11 Dec 2021 17:13:24 +0100 Subject: [PATCH] Fix formfield label touch (#10867) --- src/components/ha-formfield.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/components/ha-formfield.ts b/src/components/ha-formfield.ts index e0452e0db7..7ca076e7ea 100644 --- a/src/components/ha-formfield.ts +++ b/src/components/ha-formfield.ts @@ -1,10 +1,28 @@ import { Formfield } from "@material/mwc-formfield"; import { css, CSSResultGroup } from "lit"; import { customElement } from "lit/decorators"; +import { fireEvent } from "../common/dom/fire_event"; @customElement("ha-formfield") // @ts-expect-error 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 { return [ Formfield.styles,