From a2dbdbf8ccb740e76c9e9295560930b38c818bda Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sat, 8 Nov 2025 10:41:43 -0600 Subject: [PATCH] Fix #7274: Add unique CSS class suffix to all selectors in sheet drawings Previously, when multiple CSS selectors were comma-separated in a rule, only the last selector received the unique drawing ID suffix. This caused style conflicts when multiple drawings were placed on the same sheet. Now all selectors in comma-separated lists receive the unique suffix, ensuring proper style isolation between drawings. Example: Before: .cut.Status-DEMOLISH, .cut.Option-D.d2156 { ... } After: .cut.Status-DEMOLISH.d2156, .cut.Option-D.d2156 { ... } --- .../bonsai/bim/module/drawing/sheeter.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/sheeter.py b/src/bonsai/bonsai/bim/module/drawing/sheeter.py index 15ac314e8b..a3ec74159a 100644 --- a/src/bonsai/bonsai/bim/module/drawing/sheeter.py +++ b/src/bonsai/bonsai/bim/module/drawing/sheeter.py @@ -341,17 +341,29 @@ class SheetBuilder: assert style_data is not None text = "" brackets_level = 0 + selector_buffer = "" # Buffer to accumulate selectors across lines + for l in style_data: if l == "{": if brackets_level == 0: - cur_line = text.splitlines()[-1] - text = text[: -len(cur_line)] + # Get all accumulated selector text (may span multiple lines) + # Find where the last rule ended (after last }) or start of text + last_close = text.rfind("}") + if last_close == -1: + selector_text = text + text = "" + else: + selector_text = text[last_close + 1 :] + text = text[: last_close + 1] + + # Process all selectors (split by comma) css_selectors = [] - # making sure cases like "text, tspan" will be - # converted to "text.prefix, tspan.prefix" - for css_selector in cur_line.split(","): - css_selector = f"{css_selector.strip()}.{prefix}" - css_selectors.append(css_selector) + for css_selector in selector_text.split(","): + css_selector = css_selector.strip() + if css_selector: # Only process non-empty selectors + css_selector = f"{css_selector}.{prefix}" + css_selectors.append(css_selector) + text += ", ".join(css_selectors) + " " brackets_level += 1 elif l == "}":