mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Fix noUnderline in search input (#9339)
This commit is contained in:
parent
fe5f9576c6
commit
b05e86d442
@ -1,9 +1,16 @@
|
|||||||
import "@material/mwc-icon-button/mwc-icon-button";
|
import "@material/mwc-icon-button/mwc-icon-button";
|
||||||
import { mdiClose, mdiMagnify } from "@mdi/js";
|
import { mdiClose, mdiMagnify } from "@mdi/js";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import { customElement, property } from "lit/decorators";
|
import {
|
||||||
import { classMap } from "lit/directives/class-map";
|
css,
|
||||||
|
CSSResultGroup,
|
||||||
|
html,
|
||||||
|
LitElement,
|
||||||
|
PropertyValues,
|
||||||
|
TemplateResult,
|
||||||
|
} from "lit";
|
||||||
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import "../../components/ha-svg-icon";
|
import "../../components/ha-svg-icon";
|
||||||
import { fireEvent } from "../dom/fire_event";
|
import { fireEvent } from "../dom/fire_event";
|
||||||
|
|
||||||
@ -27,18 +34,11 @@ class SearchInput extends LitElement {
|
|||||||
this.shadowRoot!.querySelector("paper-input")!.focus();
|
this.shadowRoot!.querySelector("paper-input")!.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@query("paper-input", true) private _input!: PaperInputElement;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<style>
|
|
||||||
.no-underline:not(.focused) {
|
|
||||||
--paper-input-container-underline: {
|
|
||||||
display: none;
|
|
||||||
height: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<paper-input
|
<paper-input
|
||||||
class=${classMap({ "no-underline": this.noUnderline })}
|
|
||||||
.autofocus=${this.autofocus}
|
.autofocus=${this.autofocus}
|
||||||
.label=${this.label || "Search"}
|
.label=${this.label || "Search"}
|
||||||
.value=${this.filter}
|
.value=${this.filter}
|
||||||
@ -62,6 +62,17 @@ class SearchInput extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
if (
|
||||||
|
changedProps.has("noUnderline") &&
|
||||||
|
(this.noUnderline || changedProps.get("noUnderline") !== undefined)
|
||||||
|
) {
|
||||||
|
(this._input.inputElement!.parentElement!.shadowRoot!.querySelector(
|
||||||
|
"div.unfocused-line"
|
||||||
|
) as HTMLElement).style.display = this.noUnderline ? "none" : "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _filterChanged(value: string) {
|
private async _filterChanged(value: string) {
|
||||||
fireEvent(this, "value-changed", { value: String(value) });
|
fireEvent(this, "value-changed", { value: String(value) });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user