Disable pointer events when disabled (#6155)

This commit is contained in:
Bram Kragten 2020-06-13 08:58:21 +02:00 committed by GitHub
parent 71137032df
commit 6d6eef4e97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,28 +24,21 @@ export class HaIconButton extends LitElement {
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`
<mwc-icon-button <mwc-icon-button .label=${this.label} .disabled=${this.disabled}>
.label=${this.label}
?disabled=${this.disabled}
@click=${this._handleClick}
>
<ha-icon .icon=${this.icon}></ha-icon> <ha-icon .icon=${this.icon}></ha-icon>
</mwc-icon-button> </mwc-icon-button>
`; `;
} }
private _handleClick(ev) {
if (this.disabled) {
ev.stopPropagation();
}
}
static get styles(): CSSResult { static get styles(): CSSResult {
return css` return css`
:host { :host {
display: inline-block; display: inline-block;
outline: none; outline: none;
} }
:host([disabled]) {
pointer-events: none;
}
mwc-icon-button { mwc-icon-button {
--mdc-theme-on-primary: currentColor; --mdc-theme-on-primary: currentColor;
--mdc-theme-text-disabled-on-light: var(--disabled-text-color); --mdc-theme-text-disabled-on-light: var(--disabled-text-color);