Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Preserve scroll position in navbar after livewire update

Gabriel Avila608838045fa6
diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php
index fbb5291fbc..feb555b758 100644
--- a/resources/views/components/navbar.blade.php
+++ b/resources/views/components/navbar.blade.php
@@ -44,8 +44,15 @@
this.theme = 'system';
document.documentElement.classList.remove('dark');
}
- }
-}">
+ },
+ saveScrollPosition() {
+ localStorage.setItem('navbarScrollPosition', this.$refs.navbar.scrollTop);
+ },
+ restoreScrollPosition() {
+ this.$nextTick(() => {
+ this.$refs.navbar.scrollTop = localStorage.getItem('navbarScrollPosition') || 0;
+ });
+ }}" @livewire:load="restoreScrollPosition()" @livewire:update="saveScrollPosition()">
<div class="flex pt-6 pb-4 pl-3">
<div class="flex flex-col w-full">
<div class="text-2xl font-bold tracking-wide dark:text-white">Coolify</div>
@@ -83,7 +90,7 @@
<div class="px-2 pt-2 pb-7">
<livewire:switch-team />
</div>
- <ul role="list" class="flex flex-col flex-1 gap-y-7">
+ <ul role="list" class="flex flex-col flex-1 gap-y-7" x-ref="navbar">
<li class="flex-1 overflow-x-hidden">
<ul role="list" class="flex flex-col h-full space-y-1.5">
@if (isSubscribed() || !isCloud())
@@ -420,4 +427,4 @@
</a>
</li> --}}
</ul>
-</nav>
+</nav>
\ No newline at end of file