From 3f823573cf6f1243a5381baf05773a77e8091e0e Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 26 Mar 2025 18:44:23 +0500 Subject: [PATCH] Fix broken scroll bar in some UI lists #6439 Just found that all scroll bars for UIList kept in sync using `list_id` - it's that second argument for `UILayout.template_list` that I forgot exist, since I've never seen set it to anything besides the empty string. So in #6439 we were reusing same UIList for multiple collection props and since one of the props was empty, it was constantly resetting scroll bar position. Was about to report it as a bug to Blender but stumbled upon similar issue https://projects.blender.org/blender/blender/issues/124364 So the solution is make sure each UIList has unique `list_id`. Fyi @Moult @Gorgious56 --- src/bonsai/bonsai/bim/module/brick/ui.py | 16 ++++++++++++-- src/bonsai/bonsai/bim/module/cost/ui.py | 20 +++++++++--------- src/bonsai/bonsai/bim/module/drawing/ui.py | 23 ++++++++++++++++++--- src/bonsai/bonsai/bim/module/sequence/ui.py | 8 +++---- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/brick/ui.py b/src/bonsai/bonsai/bim/module/brick/ui.py index e7d0a1be69..a845b12e8e 100644 --- a/src/bonsai/bonsai/bim/module/brick/ui.py +++ b/src/bonsai/bonsai/bim/module/brick/ui.py @@ -178,7 +178,14 @@ class BIM_PT_brickschema_viewport(Panel): row = grid_left.row() BIM_UL_bricks.split_screen = False - row.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index") + row.template_list( + BIM_UL_bricks.__name__, + BIM_UL_bricks.__name__ + "_bricks", + self.props, + "bricks", + self.props, + "active_brick_index", + ) if self.props.split_screen_toggled: grid_right = grid.column(align=True) @@ -195,7 +202,12 @@ class BIM_PT_brickschema_viewport(Panel): row = grid_right.row() BIM_UL_bricks.split_screen = True row.template_list( - "BIM_UL_bricks", "", self.props, "split_screen_bricks", self.props, "split_screen_active_brick_index" + BIM_UL_bricks.__name__, + BIM_UL_bricks.__name__ + "_split_screen_bricks", + self.props, + "split_screen_bricks", + self.props, + "split_screen_active_brick_index", ) if BrickschemaData.data["active_relations"]: diff --git a/src/bonsai/bonsai/bim/module/cost/ui.py b/src/bonsai/bonsai/bim/module/cost/ui.py index 6897e636cc..4303af64b6 100644 --- a/src/bonsai/bonsai/bim/module/cost/ui.py +++ b/src/bonsai/bonsai/bim/module/cost/ui.py @@ -352,8 +352,8 @@ class BIM_PT_cost_item_types(Panel): row2 = col.row() row2.template_list( - "BIM_UL_cost_item_quantities", - "", + BIM_UL_cost_item_quantities.__name__, + BIM_UL_cost_item_quantities.__name__ + "_cost_item_processes", self.props, "cost_item_processes", self.props, @@ -369,8 +369,8 @@ class BIM_PT_cost_item_types(Panel): row2 = col.row() row2.template_list( - "BIM_UL_cost_item_quantities", - "", + BIM_UL_cost_item_quantities.__name__, + BIM_UL_cost_item_quantities.__name__ + "_cost_item_resources", self.props, "cost_item_resources", self.props, @@ -439,8 +439,8 @@ class BIM_PT_cost_item_quantities(Panel): row2.prop(self.props, "show_nested_elements", text="Show nested") row2 = col.row() row2.template_list( - "BIM_UL_cost_item_quantities", - "", + BIM_UL_cost_item_quantities.__name__, + BIM_UL_cost_item_quantities.__name__ + "_cost_item_products", self.props, "cost_item_products", self.props, @@ -484,8 +484,8 @@ class BIM_PT_cost_item_quantities(Panel): row2 = col.row() row2.template_list( - "BIM_UL_cost_item_quantities", - "", + BIM_UL_cost_item_quantities.__name__, + BIM_UL_cost_item_quantities.__name__ + "_cost_item_processes", self.props, "cost_item_processes", self.props, @@ -532,8 +532,8 @@ class BIM_PT_cost_item_quantities(Panel): row2 = col.row() row2.template_list( - "BIM_UL_cost_item_quantities", - "", + BIM_UL_cost_item_quantities.__name__, + BIM_UL_cost_item_quantities.__name__ + "_cost_item_resources", self.props, "cost_item_resources", self.props, diff --git a/src/bonsai/bonsai/bim/module/drawing/ui.py b/src/bonsai/bonsai/bim/module/drawing/ui.py index 6bf62ddec2..7b79499736 100644 --- a/src/bonsai/bonsai/bim/module/drawing/ui.py +++ b/src/bonsai/bonsai/bim/module/drawing/ui.py @@ -183,7 +183,14 @@ class BIM_PT_drawing_underlay(Panel): if not dprops.drawing_styles: return - layout.template_list("BIM_UL_generic", "", dprops, "drawing_styles", props, "active_drawing_style_index") + layout.template_list( + "BIM_UL_generic", + "BIM_UL_generic_drawing_styles", + dprops, + "drawing_styles", + props, + "active_drawing_style_index", + ) if not drawing_index_is_valid: return @@ -326,7 +333,12 @@ class BIM_PT_schedules(Panel): row.operator("bim.remove_schedule", icon="X", text="").schedule = active_schedule.ifc_definition_id self.layout.template_list( - "BIM_UL_generic", "", self.props, "schedules", self.props, "active_schedule_index" + "BIM_UL_generic", + "BIM_UL_generic_schedules", + self.props, + "schedules", + self.props, + "active_schedule_index", ) @@ -373,7 +385,12 @@ class BIM_PT_references(Panel): row.operator("bim.remove_reference", icon="X", text="").reference = active_reference.ifc_definition_id self.layout.template_list( - "BIM_UL_generic", "", self.props, "references", self.props, "active_reference_index" + "BIM_UL_generic", + "BIM_UL_generic_references", + self.props, + "references", + self.props, + "active_reference_index", ) diff --git a/src/bonsai/bonsai/bim/module/sequence/ui.py b/src/bonsai/bonsai/bim/module/sequence/ui.py index 3edffe170e..c996ad9d54 100644 --- a/src/bonsai/bonsai/bim/module/sequence/ui.py +++ b/src/bonsai/bonsai/bim/module/sequence/ui.py @@ -616,8 +616,8 @@ class BIM_PT_animation_Color_Scheme(Panel): row1.label(text="INPUT COLORS", icon="COLLECTION_COLOR_01") row1 = col.row() row1.template_list( - "BIM_UL_animation_colors", - "", + BIM_UL_animation_colors.__name__, + BIM_UL_animation_colors.__name__ + "_task_input_colors", self.animation_props, "task_input_colors", self.animation_props, @@ -628,8 +628,8 @@ class BIM_PT_animation_Color_Scheme(Panel): row1.label(text="OUTPUT COLORS", icon="COLLECTION_COLOR_04") row1 = col.row() row1.template_list( - "BIM_UL_animation_colors", - "", + BIM_UL_animation_colors.__name__, + BIM_UL_animation_colors.__name__ + "_task_output_colors", self.animation_props, "task_output_colors", self.animation_props,