From 5f2c3183d4aff0a8232fb9b888837989bd6ebcc4 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Wed, 27 May 2026 21:14:22 +0800 Subject: [PATCH] bugfix: remove empty headers in BIG ui --- .../ui/layouts/settings/dragonpilot.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dragonpilot/selfdrive/ui/layouts/settings/dragonpilot.py b/dragonpilot/selfdrive/ui/layouts/settings/dragonpilot.py index 2f408ac68..8e4886ba2 100644 --- a/dragonpilot/selfdrive/ui/layouts/settings/dragonpilot.py +++ b/dragonpilot/selfdrive/ui/layouts/settings/dragonpilot.py @@ -69,12 +69,23 @@ class DragonpilotLayout(Widget): self._build_dependency_maps(settings_data) for i, section in enumerate(settings_data): - if self._check_condition(section.get("condition")): - formatted_title = f"### {section['title']} ###" - self._toggles[f"title_{i}"] = simple_item(title=formatted_title) - for setting in section.get("settings", []): - if self._check_condition(setting.get("condition")) and self._check_brands(setting.get("brands")): - self._create_item(setting) + if not self._check_condition(section.get("condition")): + continue + + title_key = f"title_{i}" + self._toggles[title_key] = simple_item(title=f"### {section['title']} ###") + count_after_title = len(self._toggles) + + for setting in section.get("settings", []): + if self._check_condition(setting.get("condition")) and self._check_brands(setting.get("brands")): + self._create_item(setting) + + # Drop the header if nothing rendered under it: all items filtered out + # (brand/condition) or no device widget factory for the item type + # (e.g. dashy-only text_display/text_input/action items). Avoids an + # orphan "### Section ###" with no controls. + if len(self._toggles) == count_after_title: + del self._toggles[title_key] def _check_condition(self, condition): if not condition: