fix(ui): prevent nav rail from collapsing to zero width
CI / test (pull_request) Canceled after 0s

- Lower _NAV_MIN_WIDTH to 54px (collapsed icon-only width) so the
  splitter never allows a state where the toggle button disappears
- Auto-snap to collapsed mode when user drags below threshold instead
  of leaving the rail stuck at an unusable width

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
thanhnv
2026-09-08 23:10:29 +09:00
co-authored by Claude Opus 5
parent 4163437e4f
commit 285ba3ae94
2 changed files with 11 additions and 3 deletions
+10 -2
View File
@@ -351,10 +351,18 @@ class NavRailMixin:
self._nav_wrap.setMaximumWidth(hi)
def _on_split_moved(self, _pos: int, _index: int) -> None:
"""Người dùng kéo thanh chia: nhớ lại bề rộng thanh menu để lần mở sau giữ nguyên."""
"""Người dùng kéo thanh chia: nhớ lại bề rộng thanh menu để lần mở sau giữ nguyên.
Nếu kéo xuống dưới ngưỡng collapsed, tự động chuyển sang chế độ icon-only
thay vì để width = 0 (khiến toggle button biến mất và không thể mở lại).
"""
w = self._nav_wrap.width()
if w <= _NAV_COLLAPSED_WIDTH and not self._nav_collapsed:
self._toggle_nav()
return
if not self._nav_collapsed:
self._nav_width = max(_NAV_MIN_WIDTH,
min(self._nav_max_width(), self._nav_wrap.width()))
min(self._nav_max_width(), w))
def _toggle_nav(self) -> None:
"""Thu gọn / mở rộng thanh menu, nhớ bề rộng trước khi thu để khôi phục đúng."""
+1 -1
View File
@@ -15,7 +15,7 @@ _NAV_EXPANDED_WIDTH = 150
_NAV_COLLAPSED_WIDTH = 54
_NAV_ROW_INSET = 8
_NAV_ROW_GAP = 6
_NAV_MIN_WIDTH = 132
_NAV_MIN_WIDTH = 54
_NAV_MAX_SHARE = 0.22
_NAV_MAX_CEILING = 360