Add function to close side panel based on the browser's history. (#13944)

* Add function to close side panel based on the browser's history.

* Switched to hashchange, removed from SidePanel, added to ClientApp.svelte

* Removed unused onMount, fixed lint issue

* Removed unnecessary if statement.
This commit is contained in:
Conor Webb 2024-06-17 08:21:26 +01:00 committed by GitHub
parent c6a7bf6ed1
commit 92f9501d26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -19,6 +19,7 @@
devToolsStore,
devToolsEnabled,
environmentStore,
sidePanelStore,
} from "stores"
import NotificationDisplay from "components/overlay/NotificationDisplay.svelte"
import ConfirmationDisplay from "components/overlay/ConfirmationDisplay.svelte"
@ -102,6 +103,16 @@
embedded: !!$appStore.embedded,
})
}
const handleHashChange = () => {
const { open } = $sidePanelStore
if (open) {
sidePanelStore.actions.close()
}
}
window.addEventListener("hashchange", handleHashChange)
return () => {
window.removeEventListener("hashchange", handleHashChange)
}
})
$: {

View File

@ -29,10 +29,6 @@
}
}
// $: {
// }
// Derive visibility
$: open = $sidePanelStore.contentId === $component.id