Skip to content

Commit

Permalink
copy hass frontend code for navigating using event
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerwyn committed Dec 14, 2023
1 parent b109252 commit b77345a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/android-tv-card.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/classes/base-remote-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,21 @@ export class BaseRemoteElement extends LitElement {
return;
}
if (action.navigation_replace == true) {
window.location.replace(action.navigation_path!);
window.history.replaceState(
window.history.state?.root ? { root: true } : null,
'',
`${window.location.pathname}#${action.navigation_path}`,
);
} else {
window.location.assign(action.navigation_path!);
window.history.pushState(null, '', action.navigation_path);
}
window.dispatchEvent(
new Event('location-changed', {
bubbles: false,
cancelable: true,
composed: false,
}),
);
}

toUrl(action: IAction) {
Expand Down

0 comments on commit b77345a

Please sign in to comment.