docs(ui): scroll the sidebar so the active (bold) link is in view on load
Deep-linking into a low doc (e.g. ratings/get_ratings from the overview page) opened the right menus but sat the highlight below the sidebar's visible scroll area. scrollSidebarToActive() runs at docs Alpine init: finds the link for the current path, and if it's outside the sidebar's scrollport, moves ONLY the sidebar's own scrollTop to clamp it into the nearest edge — never the page scroll. Skips the off-canvas mobile drawer. (Same behavior as Docusaurus/MkDocs on deep links.) Live: x-init wired on docs pages, function in the shipped bundle, make test green, 146 vitests.
This commit is contained in:
1 parent
a1ac5b1541
commit
da0bae94bb
3 files changed
+30
-2
No files matched your search
@@ -71,7 +71,7 @@ func DocsLayout(nav Navigation, doc Document, user User, currentPath string) tem
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<body x-data=\"docs\" x-init=\"initializeSearch(); initializeCodeCopyButtons()\" class=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<body x-data=\"docs\" x-init=\"scrollSidebarToActive(); initializeSearch(); initializeCodeCopyButtons()\" class=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user