* Update index to make it clear what has hasn't updated to Next/React yet * Typescriptify events and experiments * Typescript the old JS for easier integration * Update release-notes.ts * Lint * Run npm i * Fix a few lint issues * Update airgap-links.ts * Update airgap-links.ts * Update set-next-env to ts * Update airgap-links.ts * Update package-lock.json * Update set-next-env.ts * Update package-lock.json * Revert "Update package-lock.json" This reverts commit b45e8250beeb700719d3b44e1092b0bbd093baba. * readd fsevents * Revert "readd fsevents" This reverts commit 419f3c35080ac4a9072f0b4e8e291e1712ce3639. * Update openapi-schema-check.yml * Revert "Update openapi-schema-check.yml" This reverts commit 5e9f4a29ea11ee343ca17291a40a751920c5b923. * Update package-lock.json * Update package-lock.json
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
export default function () {
|
|
// TODO override active classes set on server side if sidebar elements are clicked
|
|
|
|
const activeMenuItem = document.querySelector('.sidebar .active') as HTMLElement
|
|
if (!activeMenuItem) return
|
|
|
|
const verticalBufferAboveActiveItem = 40
|
|
const activeMenuItemPosition = activeMenuItem.offsetTop - verticalBufferAboveActiveItem
|
|
const menu = document.querySelector('.sidebar')
|
|
|
|
if (activeMenuItemPosition > window.innerHeight * 0.5) {
|
|
menu?.scrollTo(0, activeMenuItemPosition)
|
|
}
|
|
|
|
// if the active category is a standalone category, do not close the other open dropdowns
|
|
const activeStandaloneCategory = document.querySelectorAll(
|
|
'.sidebar-category.active.standalone-category'
|
|
)
|
|
if (activeStandaloneCategory.length) return
|
|
|
|
const allOpenDetails = document.querySelectorAll('.sidebar-category:not(.active) details[open]')
|
|
|
|
if (allOpenDetails) {
|
|
for (const openDetail of Array.from(allOpenDetails)) {
|
|
openDetail.removeAttribute('open')
|
|
const svgArrowElem = openDetail.querySelector('summary > div > svg')
|
|
svgArrowElem?.remove()
|
|
}
|
|
}
|
|
}
|