mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Close dialogs on history back (#6354)
This commit is contained in:
@@ -16,6 +16,7 @@ import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { DialogParams } from "./show-dialog-box";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
@customElement("dialog-box")
|
||||
class DialogBox extends LitElement {
|
||||
@@ -32,6 +33,17 @@ class DialogBox extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
public closeDialog(): boolean {
|
||||
if (this._params?.confirmation || this._params?.prompt) {
|
||||
this._dismiss();
|
||||
return true;
|
||||
}
|
||||
if (this._params) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
@@ -100,11 +112,11 @@ class DialogBox extends LitElement {
|
||||
this._value = ev.detail.value;
|
||||
}
|
||||
|
||||
private async _dismiss(): Promise<void> {
|
||||
private _dismiss(): void {
|
||||
if (this._params!.cancel) {
|
||||
this._params!.cancel();
|
||||
}
|
||||
this._params = undefined;
|
||||
this._close();
|
||||
}
|
||||
|
||||
private _handleKeyUp(ev: KeyboardEvent) {
|
||||
@@ -113,15 +125,16 @@ class DialogBox extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _confirm(): Promise<void> {
|
||||
private _confirm(): void {
|
||||
if (this._params!.confirm) {
|
||||
this._params!.confirm(this._value);
|
||||
}
|
||||
this._dismiss();
|
||||
this._close();
|
||||
}
|
||||
|
||||
private _close(): void {
|
||||
this._params = undefined;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
|
||||
Reference in New Issue
Block a user