diff --git a/frappe/public/js/frappe/ui/sidebar/sidebar.js b/frappe/public/js/frappe/ui/sidebar/sidebar.js index 4dbee57dbb..3a1ebcaf36 100644 --- a/frappe/public/js/frappe/ui/sidebar/sidebar.js +++ b/frappe/public/js/frappe/ui/sidebar/sidebar.js @@ -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; + } } }