From dc027adf0092b6fec11f033eb0f51bf48832f828 Mon Sep 17 00:00:00 2001 From: appel_c Date: Wed, 25 Feb 2026 16:00:43 +0100 Subject: [PATCH] fix(main-app): skip on_enter/exit hooks if darkmodebutton clicked --- bec_widgets/applications/main_app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bec_widgets/applications/main_app.py b/bec_widgets/applications/main_app.py index b4069603..a4b168dd 100644 --- a/bec_widgets/applications/main_app.py +++ b/bec_widgets/applications/main_app.py @@ -185,6 +185,15 @@ class BECMainApp(BECMainWindow): # Internal: route sidebar selection to the stack def _on_view_selected(self, vid: str) -> None: + # Special handling for views that can not be switched to (e.g. dark mode toggle) + # Not registered as proper view with a stack index, so we ignore any logic below + # as it will anyways not result in a stack switch. + idx = self._view_index.get(vid) + if idx is None or not (0 <= idx < self.stack.count()): + return + # if vid == "dark_mode": + # # Special handling for dark mode toggle item + # return # Determine current view current_index = self.stack.currentIndex() current_view = (