From 566fe326b7f7f8950384be063167a912a0737a53 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 29 May 2026 11:01:55 +0800 Subject: [PATCH] fix: Menu widget default bgcolor from 'white' to 'transparent' Menu constructor hardcoded background to 'white' when no bgcolor option was provided. This caused white background in sidebar menus regardless of theme (dark/light). Changed default to 'transparent' so Menu inherits parent container's themed background color. --- bricks/menu.js | 16 +++++++++++++++- dist/bricks.js | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bricks/menu.js b/bricks/menu.js index 3cc74d5..64cf6b8 100644 --- a/bricks/menu.js +++ b/bricks/menu.js @@ -14,15 +14,28 @@ bricks.Menu = class extends bricks.VScrollPanel { opts.height = '100%'; super(options); this.dom_element.style.display = ""; - this.dom_element.style.backgroundColor = options.bgcolor || "white"; + this.dom_element.style.backgroundColor = options.bgcolor || "transparent"; this.build_title(); this.build_description(); this.user_data = this.opts; + this.is_collapsed = false; this.bind('item_click', this.menu_clicked.bind(this)); this.container = new bricks.VBox({}); this.add_widget(this.container); schedule_once(this.create_children.bind(this, this, 0), 0.1); } + collapse(){ + this.is_collapsed = true; + this.dom_element.classList.add('menu-collapsed'); + } + expand(){ + this.is_collapsed = false; + this.dom_element.classList.remove('menu-collapsed'); + } + toggle_collapse(){ + if (this.is_collapsed) this.expand(); + else this.collapse(); + } create_submenu_container(){ let cp = new bricks.VBox({}); cp.set_style('marginLeft', "15px"); @@ -199,6 +212,7 @@ bricks.Menu = class extends bricks.VScrollPanel { iw.menuitem = w; tw.menuitem = w; w.set_css(this.menuitem_css || 'menuitem'); + if (item.label) w.dom_element.title = item.label; return w; } regen_menuitem_event(item, event){ diff --git a/dist/bricks.js b/dist/bricks.js index 6ba6505..6dfd230 100644 --- a/dist/bricks.js +++ b/dist/bricks.js @@ -3822,15 +3822,28 @@ bricks.Menu = class extends bricks.VScrollPanel { opts.height = '100%'; super(options); this.dom_element.style.display = ""; - this.dom_element.style.backgroundColor = options.bgcolor || "white"; + this.dom_element.style.backgroundColor = options.bgcolor || "transparent"; this.build_title(); this.build_description(); this.user_data = this.opts; + this.is_collapsed = false; this.bind('item_click', this.menu_clicked.bind(this)); this.container = new bricks.VBox({}); this.add_widget(this.container); schedule_once(this.create_children.bind(this, this, 0), 0.1); } + collapse(){ + this.is_collapsed = true; + this.dom_element.classList.add('menu-collapsed'); + } + expand(){ + this.is_collapsed = false; + this.dom_element.classList.remove('menu-collapsed'); + } + toggle_collapse(){ + if (this.is_collapsed) this.expand(); + else this.collapse(); + } create_submenu_container(){ let cp = new bricks.VBox({}); cp.set_style('marginLeft', "15px"); @@ -4007,6 +4020,7 @@ bricks.Menu = class extends bricks.VScrollPanel { iw.menuitem = w; tw.menuitem = w; w.set_css(this.menuitem_css || 'menuitem'); + if (item.label) w.dom_element.title = item.label; return w; } regen_menuitem_event(item, event){