mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
Fix ha-selector-object not updating in the ui when new value is pushed from the parent (#15022)
Co-authored-by: Bram Kragten <mail@bramkragten.nl> fixes undefined
This commit is contained in:
parent
0bbe6151ed
commit
3675a2b013
@ -1,9 +1,10 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { html, LitElement, PropertyValues } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-yaml-editor";
|
import "../ha-yaml-editor";
|
||||||
import "../ha-input-helper-text";
|
import "../ha-input-helper-text";
|
||||||
|
import type { HaYamlEditor } from "../ha-yaml-editor";
|
||||||
|
|
||||||
@customElement("ha-selector-object")
|
@customElement("ha-selector-object")
|
||||||
export class HaObjectSelector extends LitElement {
|
export class HaObjectSelector extends LitElement {
|
||||||
@ -21,6 +22,10 @@ export class HaObjectSelector extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
|
|
||||||
|
@query("ha-yaml-editor", true) private _yamlEditor!: HaYamlEditor;
|
||||||
|
|
||||||
|
private _valueChangedFromChild = false;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`<ha-yaml-editor
|
return html`<ha-yaml-editor
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@ -36,7 +41,16 @@ export class HaObjectSelector extends LitElement {
|
|||||||
: ""} `;
|
: ""} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
super.updated(changedProps);
|
||||||
|
if (changedProps.has("value") && !this._valueChangedFromChild) {
|
||||||
|
this._yamlEditor.setValue(this.value);
|
||||||
|
}
|
||||||
|
this._valueChangedFromChild = false;
|
||||||
|
}
|
||||||
|
|
||||||
private _handleChange(ev) {
|
private _handleChange(ev) {
|
||||||
|
this._valueChangedFromChild = true;
|
||||||
const value = ev.target.value;
|
const value = ev.target.value;
|
||||||
if (!ev.target.isValid) {
|
if (!ev.target.isValid) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user