fix initial slideUp glitch in treeview

master
Daniel 2025-08-04 14:58:53 +05:30
parent 3001b30742
commit b17340cdf0
1 changed files with 13 additions and 1 deletions

View File

@ -24,7 +24,7 @@ const EVENT_KEY = `.${DATA_KEY}`
const EVENT_EXPANDED = `expanded${EVENT_KEY}`
const EVENT_COLLAPSED = `collapsed${EVENT_KEY}`
// const EVENT_LOAD_DATA_API = `load${EVENT_KEY}`
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}`
const CLASS_NAME_MENU_OPEN = 'menu-open'
const SELECTOR_NAV_ITEM = '.nav-item'
@ -112,6 +112,18 @@ class Treeview {
*/
onDOMContentLoaded(() => {
const openMenuItems = document.querySelectorAll(`${SELECTOR_NAV_ITEM}.${CLASS_NAME_MENU_OPEN}`)
openMenuItems.forEach(menuItem => {
const childElement = menuItem.querySelector(SELECTOR_TREEVIEW_MENU) as HTMLElement | undefined
if (childElement) {
slideDown(childElement, 0)
const event = new Event(EVENT_LOAD_DATA_API)
menuItem.dispatchEvent(event)
}
})
const button = document.querySelectorAll(SELECTOR_DATA_TOGGLE)
button.forEach(btn => {