chore: fix topbar behavior & add missing alias

This commit is contained in:
Zach Daniel 2023-02-02 00:51:54 -05:00
parent 8f98cd17e4
commit fef150c941
2 changed files with 4 additions and 3 deletions

View file

@ -220,7 +220,7 @@ let liveSocket = new LiveSocket("/live", Socket, {
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" });
let topBarScheduled = undefined;
window.addEventListener("phx:page-loading-start", () => {
window.addEventListener("phx:page-loading-start", ({ detail }) => {
scrolled = false;
// close mobile sidebar on navigation
@ -229,13 +229,14 @@ window.addEventListener("phx:page-loading-start", () => {
mobileSideBar.click()
}
if (!topBarScheduled) {
if (detail.kind !== 'patch' && !topBarScheduled) {
topBarScheduled = setTimeout(() => topbar.show(), 500);
}
});
window.addEventListener("phx:page-loading-stop", ({ detail }) => {
clearTimeout(topBarScheduled);
topbar.hide();
topBarScheduled = undefined;
let scrollEl;
if (detail.kind === "initial" && window.location.hash) {
@ -251,7 +252,6 @@ window.addEventListener("phx:page-loading-stop", ({ detail }) => {
} else {
scrolled = true;
}
topbar.hide();
});
window.addEventListener("js:focus", (e) => e.target.focus());

View file

@ -8,6 +8,7 @@ defmodule AshHqWeb.Components.TreeView do
use Surface.Component
alias AshHqWeb.Components.TreeView.Item
alias Surface.Components.LivePatch
alias Phoenix.LiveView.JS
alias Surface.Components.LivePatch