Merge pull request #35921 from claytonlin1110/fix/sidebar-auto-expand-nested

This commit is contained in:
Soham Kulkarni 2026-01-14 01:25:54 +05:30 committed by GitHub
commit 43393bc4f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,6 +155,34 @@ frappe.ui.Sidebar = class Sidebar {
set_active_workspace_item() {
if (this.is_route_in_sidebar()) {
this.active_item.addClass("active-sidebar");
this.expand_parent_section();
}
}
expand_parent_section() {
if (!this.active_item) return;
let active_section;
$(".section-item").each((index, element) => {
if (element.contains(this.active_item.get(0))) {
active_section = element.dataset.id;
}
});
if (active_section) {
let section = this.get_item(active_section);
if (section) {
if (section.collapsed) {
section.open();
}
}
}
}
get_item(name) {
for (let item of this.items) {
if (item.item.label === name) {
return item;
}
}
}