From 6db6d792111c523455d9bdc0ac817e2f534f50e7 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 24 Feb 2026 15:34:48 -0800 Subject: [PATCH] WifiUi: decouple button update from move/scroll (#37383) * meh * hmm * can also do this * keep behavior * rm --- .../mici/layouts/settings/network/wifi_ui.py | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/selfdrive/ui/mici/layouts/settings/network/wifi_ui.py b/selfdrive/ui/mici/layouts/settings/network/wifi_ui.py index 2efc45f46a..ec6b0c9dc5 100644 --- a/selfdrive/ui/mici/layouts/settings/network/wifi_ui.py +++ b/selfdrive/ui/mici/layouts/settings/network/wifi_ui.py @@ -325,19 +325,11 @@ class WifiUIMici(NavWidget): if isinstance(btn, WifiButton) and btn.network.ssid not in self._networks: btn.set_network_missing(True) - # Move connecting/connected network to the front with animation - front_ssid = self._wifi_manager.wifi_state.ssid - front_btn_idx = next((i for i, btn in enumerate(self._scroller.items) - if isinstance(btn, WifiButton) and - btn.network.ssid == front_ssid), None) if front_ssid else None - - if front_btn_idx is not None and front_btn_idx > 0: - self._scroller.move_item(front_btn_idx, 0) + self._move_network_to_front(self._wifi_manager.wifi_state.ssid) def _connect_with_password(self, ssid: str, password: str): self._wifi_manager.connect_to_network(ssid, password) - self._scroller.scroll_to(self._scroller.scroll_panel.get_offset(), smooth=True) - self._update_buttons() + self._move_network_to_front(ssid, scroll=True) def _connect_to_network(self, ssid: str): network = self._networks.get(ssid) @@ -353,8 +345,7 @@ class WifiUIMici(NavWidget): self._on_need_auth(network.ssid, False) return - self._scroller.scroll_to(self._scroller.scroll_panel.get_offset(), smooth=True) - self._update_buttons() + self._move_network_to_front(ssid, scroll=True) def _on_need_auth(self, ssid, incorrect_password=True): if incorrect_password: @@ -374,6 +365,19 @@ class WifiUIMici(NavWidget): if isinstance(btn, WifiButton) and btn.network.ssid == ssid: btn.on_forgotten() + def _move_network_to_front(self, ssid: str | None, scroll: bool = False): + # Move connecting/connected network to the front with animation + front_btn_idx = next((i for i, btn in enumerate(self._scroller.items) + if isinstance(btn, WifiButton) and + btn.network.ssid == ssid), None) if ssid else None + + if front_btn_idx is not None and front_btn_idx > 0: + self._scroller.move_item(front_btn_idx, 0) + + if scroll: + # Scroll to the new position of the network + self._scroller.scroll_to(self._scroller.scroll_panel.get_offset(), smooth=True) + def _update_state(self): super()._update_state()