mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 14:07:55 +00:00
Fix opening edit dialog twice when closed by clicking on overlay (#2290)
This commit is contained in:
parent
47635055d0
commit
71ed83ef07
@ -58,6 +58,7 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
<hui-dialog-pick-card
|
<hui-dialog-pick-card
|
||||||
.hass="${this.hass}"
|
.hass="${this.hass}"
|
||||||
.cardPicked="${this._cardPicked}"
|
.cardPicked="${this._cardPicked}"
|
||||||
|
.closeDialog="${this._cancel}"
|
||||||
></hui-dialog-pick-card>
|
></hui-dialog-pick-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import { LovelaceCardConfig } from "../../../../data/lovelace";
|
|||||||
export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
|
export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
|
||||||
public hass?: HomeAssistant;
|
public hass?: HomeAssistant;
|
||||||
public cardPicked?: (cardConf: LovelaceCardConfig) => void;
|
public cardPicked?: (cardConf: LovelaceCardConfig) => void;
|
||||||
|
public closeDialog?: () => void;
|
||||||
|
|
||||||
static get properties(): PropertyDeclarations {
|
static get properties(): PropertyDeclarations {
|
||||||
return {};
|
return {};
|
||||||
@ -18,7 +19,11 @@ export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<paper-dialog with-backdrop opened>
|
<paper-dialog
|
||||||
|
with-backdrop
|
||||||
|
opened
|
||||||
|
@opened-changed="${this._openedChanged}"
|
||||||
|
>
|
||||||
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2>
|
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2>
|
||||||
<paper-dialog-scrollable>
|
<paper-dialog-scrollable>
|
||||||
<hui-card-picker
|
<hui-card-picker
|
||||||
@ -33,6 +38,12 @@ export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _openedChanged(ev) {
|
||||||
|
if (!ev.detail.value) {
|
||||||
|
this.closeDialog!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _skipPick() {
|
private _skipPick() {
|
||||||
this.cardPicked!({ type: "" });
|
this.cardPicked!({ type: "" });
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,11 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this.renderStyle()}
|
${this.renderStyle()}
|
||||||
<paper-dialog with-backdrop opened>
|
<paper-dialog
|
||||||
|
with-backdrop
|
||||||
|
opened
|
||||||
|
@opened-changed="${this._openedChanged}"
|
||||||
|
>
|
||||||
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2>
|
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2>
|
||||||
<paper-spinner
|
<paper-spinner
|
||||||
?active="${this._loading}"
|
?active="${this._loading}"
|
||||||
@ -436,6 +440,12 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
private get _creatingCard(): boolean {
|
private get _creatingCard(): boolean {
|
||||||
return this.path!.length === 1;
|
return this.path!.length === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _openedChanged(ev) {
|
||||||
|
if (!ev.detail.value) {
|
||||||
|
this.closeDialog!();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user