Hopefully fix some back button issues (#8708)

This commit is contained in:
Bram Kragten 2021-03-29 11:29:43 +02:00 committed by GitHub
parent 742028b691
commit 7f7d89c745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 8 deletions

View File

@ -36,11 +36,11 @@ class DialogBox extends LitElement {
public closeDialog(): boolean {
if (this._params?.confirmation || this._params?.prompt) {
this._dismiss();
return true;
return false;
}
if (this._params) {
return false;
this._dismiss();
return true;
}
return true;
}
@ -140,7 +140,7 @@ class DialogBox extends LitElement {
}
private _dialogClosed(ev) {
if (this._params?.prompt && ev.detail.action === "ignore") {
if (ev.detail.action === "ignore") {
return;
}
this._dismiss();

View File

@ -186,7 +186,7 @@ class HassTabsSubpage extends LitElement {
}
private _tabTapped(ev: Event): void {
navigate(this, (ev.currentTarget as any).path, true);
navigate(this, (ev.currentTarget as any).path);
}
private _backTapped(): void {
@ -230,7 +230,6 @@ class HassTabsSubpage extends LitElement {
padding: 0 16px;
box-sizing: border-box;
}
#tabbar {
display: flex;
font-size: 14px;

View File

@ -40,6 +40,12 @@ export const urlSyncMixin = <
) => {
if (DEBUG) {
console.log("dialog closed", ev.detail.dialog);
console.log(
"open",
history.state?.open,
"dialog",
history.state?.dialog
);
}
// If not closed by navigating back, and not a new dialog is open, remove the open state from history
if (
@ -56,8 +62,11 @@ export const urlSyncMixin = <
private _popstateChangeListener = (ev: PopStateEvent) => {
if (this._ignoreNextPopState) {
if (ev.state?.oldState?.replaced) {
// if the previous dialog was replaced, and the current dialog is closed, we should also remove the replaced dialog from history
if (
ev.state?.oldState?.replaced ||
ev.state?.oldState?.dialogParams === null
) {
// if the previous dialog was replaced, or we could not copy the params, and the current dialog is closed, we should also remove the previous dialog from history
if (DEBUG) {
console.log("remove old state", ev.state.oldState);
}