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:
@@ -76,6 +76,12 @@ export const SidebarItemLink = ({
|
||||
newTopCalculator,
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
if (active && isMobile) {
|
||||
setSidebarOpen(false)
|
||||
}
|
||||
}, [active, isMobile])
|
||||
|
||||
const hasChildren = useMemo(() => {
|
||||
return !item.isChildSidebar && (item.children?.length || 0) > 0
|
||||
}, [item.children])
|
||||
@@ -108,14 +114,6 @@ export const SidebarItemLink = ({
|
||||
"flex justify-between items-center gap-[6px]",
|
||||
className
|
||||
)}
|
||||
scroll={true}
|
||||
onClick={() => {
|
||||
if (isMobile) {
|
||||
setSidebarOpen(false)
|
||||
}
|
||||
}}
|
||||
replace={!item.isPathHref}
|
||||
shallow={!item.isPathHref}
|
||||
{...item.linkProps}
|
||||
>
|
||||
<span
|
||||
|
||||
Reference in New Issue
Block a user