mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 01:04:34 +03:00
Fix bug with anchor links after reloading
There was no need for the previous implementation, since the browser handles this nativly. Additional the manual scrolling into view was actually broken, because the heading would disappear behind the menu bar.
This commit is contained in:
parent
207c9d9e1c
commit
d6c9a07faa
|
@ -38,7 +38,6 @@ const DropdownNavigation = ({ items, defaultValue }) => {
|
|||
}
|
||||
|
||||
export default function Sidebar({ items = [], pageMenu = [], slug }) {
|
||||
const [initialized, setInitialized] = useState(false)
|
||||
const [activeSection, setActiveSection] = useState(null)
|
||||
const activeRef = useRef()
|
||||
const activeHeading = getActiveHeading(items, slug)
|
||||
|
@ -46,16 +45,10 @@ export default function Sidebar({ items = [], pageMenu = [], slug }) {
|
|||
useEffect(() => {
|
||||
const handleInView = ({ detail }) => setActiveSection(detail)
|
||||
window.addEventListener('inview', handleInView, { passive: true })
|
||||
if (!initialized) {
|
||||
if (activeRef && activeRef.current) {
|
||||
activeRef.current.scrollIntoView({ block: 'center' })
|
||||
}
|
||||
setInitialized(true)
|
||||
}
|
||||
return () => {
|
||||
window.removeEventListener('inview', handleInView)
|
||||
}
|
||||
}, [initialized])
|
||||
})
|
||||
|
||||
return (
|
||||
<menu className={classNames('sidebar', classes['root'])}>
|
||||
|
|
Loading…
Reference in New Issue
Block a user