Preserve sidebar scroll position when navigating between documents

- Add x-navigate:scroll directive to sidebar container to maintain scroll position
- Add x-navigate:scroll to all document links in sidebar (tree-item.blade.php)
- Add x-navigate:scroll to 'New Document' button
- When clicking a link in sidebar, the sidebar scroll position is now preserved during page navigation
- Fixes issue where sidebar would scroll to top after loading a document
This commit is contained in:
2025-12-04 01:37:19 +09:00
parent b96012f598
commit e66ece71e3
3 changed files with 3 additions and 0 deletions

View File

@@ -200,6 +200,7 @@ class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 ring-1 ring
<div class="flex h-[calc(100vh-4rem)]"> <div class="flex h-[calc(100vh-4rem)]">
<!-- Sidebar - Desktop --> <!-- Sidebar - Desktop -->
<aside <aside
x-navigate:scroll
class="hidden lg:block bg-white border-r border-gray-200 overflow-y-auto relative" class="hidden lg:block bg-white border-r border-gray-200 overflow-y-auto relative"
:style="'width: ' + sidebarWidth + 'px'" :style="'width: ' + sidebarWidth + 'px'"
> >

View File

@@ -18,6 +18,7 @@
@auth @auth
<div class="mt-6 pt-6 border-t border-gray-200"> <div class="mt-6 pt-6 border-t border-gray-200">
<a <a
x-navigate:scroll
href="{{ route('documents.create') }}" href="{{ route('documents.create') }}"
class="flex items-center justify-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-md hover:bg-indigo-700" class="flex items-center justify-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-md hover:bg-indigo-700"
> >

View File

@@ -8,6 +8,7 @@
$displayTitle = basename($file['document']->title); $displayTitle = basename($file['document']->title);
@endphp @endphp
<a <a
x-navigate:scroll
href="{{ route('documents.show', $file['document']) }}" href="{{ route('documents.show', $file['document']) }}"
class="flex items-center px-2 py-1.5 text-sm text-gray-700 rounded hover:bg-gray-100 group" class="flex items-center px-2 py-1.5 text-sm text-gray-700 rounded hover:bg-gray-100 group"
> >