docs,api-ref: design + algolia fixes (#4775)

* fix algolia results on same page

* fix navigation bar for mobile

* fix eslint configurations

* fix github action

* fix search icon on mobile

* fix code block dark mode
This commit is contained in:
Shahed Nasser
2023-08-16 11:38:50 +03:00
committed by GitHub
parent 914d773d3a
commit 9cc0bc6c9d
19 changed files with 62 additions and 41 deletions

View File

@@ -259,6 +259,14 @@ const SidebarProvider = ({ children }: SidebarProviderProps) => {
}
}
// this is mainly triggered by Algolia
const handleHashChange = useCallback(() => {
const currentPath = location.hash.replace("#", "")
if (currentPath !== activePath) {
setActivePath(currentPath)
}
}, [activePath])
useEffect(() => {
init()
@@ -271,13 +279,6 @@ const SidebarProvider = ({ children }: SidebarProviderProps) => {
}
}
const handleHashChange = () => {
const currentPath = location.hash.replace("#", "")
if (currentPath !== activePath) {
setActivePath(currentPath)
}
}
window.addEventListener("scroll", handleScroll)
window.addEventListener("hashchange", handleHashChange)
@@ -285,7 +286,7 @@ const SidebarProvider = ({ children }: SidebarProviderProps) => {
window.removeEventListener("scroll", handleScroll)
window.removeEventListener("hashchange", handleHashChange)
}
}, [])
}, [handleHashChange])
return (
<SidebarContext.Provider