diff --git a/src/components/Layout.jsx b/src/components/Layout.jsx
index 77a047ae..a3c8d83e 100644
--- a/src/components/Layout.jsx
+++ b/src/components/Layout.jsx
@@ -103,7 +103,7 @@ function useTableOfContents(tableOfContents) {
if (tableOfContents.length === 0) return
let headings = getHeadings(tableOfContents)
function onScroll() {
- let top = window.scrollY
+ let top = window.scrollY + 10;
let current = headings[0]?.id
for (let heading of headings) {
if (top >= heading?.top) {
diff --git a/src/components/NavigationDocs.jsx b/src/components/NavigationDocs.jsx
index 970e7483..aae7db51 100644
--- a/src/components/NavigationDocs.jsx
+++ b/src/components/NavigationDocs.jsx
@@ -217,10 +217,7 @@ export const docsNavigation = [
const [isOpen, setIsOpen] = useState(group.isOpen ? group.isOpen :!hasChildren);
const [, setActiveHighlight] = useNavigationState();
-
return (
-
-
{
setIsOpen(!isOpen)
if(!isOpen) {
- router.push(group.links[0].href)
+ if(!isActiveGroup) router.push(group.links[0].href)
setActiveHighlight()
}else {
setActiveHighlight(group.title)
}
}}
data-nb-link={group.title}
+ data-nb-active={hasChildren && isActiveGroup ? "1" : "0"}
>
{group.title}
{hasChildren && }
diff --git a/src/components/NavigationState.jsx b/src/components/NavigationState.jsx
index bc0e17ab..53847973 100644
--- a/src/components/NavigationState.jsx
+++ b/src/components/NavigationState.jsx
@@ -18,8 +18,9 @@ export function NavigationStateProvider({ children,index }) {
});
links.shift();
+ const activeGroupTitle = groupTitle ? groupTitle : document.querySelector(`.outer-wrapper-${index} [data-nb-active="1"]`)?.getAttribute('data-nb-link');
const activeIndex = links.findIndex((link) => link === "1");
- const activeGroupIndex = links.findIndex((link) => link === groupTitle);
+ const activeGroupIndex = links.findIndex((link) => link === activeGroupTitle);
if(activeGroupIndex !== -1 && activeIndex === -1){
setActiveIndex(activeGroupIndex);
@@ -30,7 +31,7 @@ export function NavigationStateProvider({ children,index }) {
}
useEffect(() => {
- setActiveHighlight();
+ setActiveHighlight().then();
}, [router.pathname]);
return (