mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 21:47:46 +00:00
Save height and width when you start filtering to make timing less fragile
This commit is contained in:
parent
737f7ba6b9
commit
21e441b682
@ -21,7 +21,6 @@ import { brandsUrl } from "../../util/brands-url";
|
|||||||
import { documentationUrl } from "../../util/documentation-url";
|
import { documentationUrl } from "../../util/documentation-url";
|
||||||
import { configFlowContentStyles } from "./styles";
|
import { configFlowContentStyles } from "./styles";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { afterNextRender } from "../../common/util/render-status";
|
|
||||||
|
|
||||||
interface HandlerObj {
|
interface HandlerObj {
|
||||||
name: string;
|
name: string;
|
||||||
@ -147,10 +146,26 @@ class StepFlowPickHandler extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public willUpdate(changedProps: PropertyValues): void {
|
public willUpdate(changedProps: PropertyValues): void {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
if (this._filter === undefined && this.initialFilter !== undefined) {
|
if (this._filter === undefined && this.initialFilter !== undefined) {
|
||||||
this._filter = this.initialFilter;
|
this._filter = this.initialFilter;
|
||||||
}
|
}
|
||||||
super.willUpdate(changedProps);
|
if (this.initialFilter !== undefined && this._filter === "") {
|
||||||
|
this.initialFilter = undefined;
|
||||||
|
this._filter = "";
|
||||||
|
this._width = undefined;
|
||||||
|
this._height = undefined;
|
||||||
|
} else if (
|
||||||
|
this.hasUpdated &&
|
||||||
|
changedProps.has("_filter") &&
|
||||||
|
(!this._width || !this._height)
|
||||||
|
) {
|
||||||
|
// Store the width and height so that when we search, box doesn't jump
|
||||||
|
const boundingRect =
|
||||||
|
this.shadowRoot!.querySelector("div")!.getBoundingClientRect();
|
||||||
|
this._width = boundingRect.width;
|
||||||
|
this._height = boundingRect.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
@ -161,21 +176,6 @@ class StepFlowPickHandler extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps) {
|
|
||||||
super.updated(changedProps);
|
|
||||||
// Store the width and height so that when we search, box doesn't jump
|
|
||||||
if (!this._width || !this._height) {
|
|
||||||
this.updateComplete.then(() => {
|
|
||||||
afterNextRender(() => {
|
|
||||||
const boundingRect =
|
|
||||||
this.shadowRoot!.querySelector("div")!.getBoundingClientRect();
|
|
||||||
this._width = boundingRect.width;
|
|
||||||
this._height = boundingRect.height;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _getHandlers() {
|
private _getHandlers() {
|
||||||
return this._filterHandlers(
|
return this._filterHandlers(
|
||||||
this.handlers,
|
this.handlers,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user