From b17340cdf0bb8cc36055b6e188636840127110e2 Mon Sep 17 00:00:00 2001 From: Daniel <50356015+danny007in@users.noreply.github.com> Date: Mon, 4 Aug 2025 14:58:53 +0530 Subject: [PATCH] fix initial slideUp glitch in treeview --- src/ts/treeview.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ts/treeview.ts b/src/ts/treeview.ts index 7b9b961d1..d2cffd23d 100644 --- a/src/ts/treeview.ts +++ b/src/ts/treeview.ts @@ -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 => {