docs: DX and performance improvements in API reference (#9430)
- Improve scroll behavior between active sections - Improve lag when clicking on a sidebar item - Refactor internal working of the `SidebarProvider` to find active items faster. - Use Next.js's `useRouter` hook for changing the hash (since they added the option to disable scroll) - Change `isBrowser` from a hook to a provider since it's widely used across applications. - Other general improvements and fixes. Closes DOCS-952
This commit is contained in:
@@ -12,7 +12,7 @@ type PageTitleProviderProps = {
|
||||
}
|
||||
|
||||
const PageTitleProvider = ({ children }: PageTitleProviderProps) => {
|
||||
const { activePath, getActiveItem } = useSidebar()
|
||||
const { activePath, activeItem } = useSidebar()
|
||||
const { area } = useArea()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -21,7 +21,6 @@ const PageTitleProvider = ({ children }: PageTitleProviderProps) => {
|
||||
if (!activePath?.length) {
|
||||
document.title = titleSuffix
|
||||
} else {
|
||||
const activeItem = getActiveItem()
|
||||
if (activeItem?.path === activePath) {
|
||||
document.title = `${activeItem?.title} - ${titleSuffix}`
|
||||
} else {
|
||||
@@ -34,7 +33,7 @@ const PageTitleProvider = ({ children }: PageTitleProviderProps) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [activePath, area, getActiveItem])
|
||||
}, [activePath, area, activeItem])
|
||||
|
||||
return (
|
||||
<PageTitleContext.Provider value={null}>
|
||||
|
||||
Reference in New Issue
Block a user