Skip to content

Commit

Permalink
#3209 Make the sidebar scroll into view of the active item
Browse files Browse the repository at this point in the history
Signed-off-by: James Hunt <[email protected]>
  • Loading branch information
thetwopct committed Dec 29, 2024
1 parent 01253b7 commit ad4651a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions layouts/partials/sidebar-tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</form>
<div class="search-by-tag">
<a href="{{ relref . "/tags" }}">{{ T "ui_or_search_by_tags" }}</a>
</div>
</div>
{{ else -}}
<div id="content-mobile">
<form class="td-sidebar__search d-flex align-items-center">
Expand Down Expand Up @@ -74,4 +74,16 @@
</ul>
{{- end }}
</li>
{{- end }}
{{- end }}

<script>
document.addEventListener("DOMContentLoaded", function () {
const activeLink = document.querySelector(".td-sidebar-nav__section .active");
if (activeLink) {
activeLink.scrollIntoView({
behavior: "smooth",
block: "center",
});
}
});
</script>

0 comments on commit ad4651a

Please sign in to comment.