Fix opening edit dialog twice when closed by clicking on overlay (#2290)

This commit is contained in:
Paulus Schoutsen 2018-12-13 21:46:57 +01:00 committed by GitHub
parent 47635055d0
commit 71ed83ef07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View File

@ -58,6 +58,7 @@ export class HuiDialogEditCard extends LitElement {
<hui-dialog-pick-card
.hass="${this.hass}"
.cardPicked="${this._cardPicked}"
.closeDialog="${this._cancel}"
></hui-dialog-pick-card>
`;
}

View File

@ -11,6 +11,7 @@ import { LovelaceCardConfig } from "../../../../data/lovelace";
export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
public hass?: HomeAssistant;
public cardPicked?: (cardConf: LovelaceCardConfig) => void;
public closeDialog?: () => void;
static get properties(): PropertyDeclarations {
return {};
@ -18,7 +19,11 @@ export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
protected render(): TemplateResult {
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>
<paper-dialog-scrollable>
<hui-card-picker
@ -33,6 +38,12 @@ export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
`;
}
private _openedChanged(ev) {
if (!ev.detail.value) {
this.closeDialog!();
}
}
private _skipPick() {
this.cardPicked!({ type: "" });
}

View File

@ -132,7 +132,11 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
return html`
${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>
<paper-spinner
?active="${this._loading}"
@ -436,6 +440,12 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
private get _creatingCard(): boolean {
return this.path!.length === 1;
}
private _openedChanged(ev) {
if (!ev.detail.value) {
this.closeDialog!();
}
}
}
declare global {