mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Disable pointer events when disabled (#6155)
This commit is contained in:
parent
71137032df
commit
6d6eef4e97
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user