- 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:
@@ -351,10 +351,18 @@ class NavRailMixin:
|
|||||||
self._nav_wrap.setMaximumWidth(hi)
|
self._nav_wrap.setMaximumWidth(hi)
|
||||||
|
|
||||||
def _on_split_moved(self, _pos: int, _index: int) -> None:
|
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:
|
if not self._nav_collapsed:
|
||||||
self._nav_width = max(_NAV_MIN_WIDTH,
|
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:
|
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."""
|
"""Thu gọn / mở rộng thanh menu, nhớ bề rộng trước khi thu để khôi phục đúng."""
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ _NAV_EXPANDED_WIDTH = 150
|
|||||||
_NAV_COLLAPSED_WIDTH = 54
|
_NAV_COLLAPSED_WIDTH = 54
|
||||||
_NAV_ROW_INSET = 8
|
_NAV_ROW_INSET = 8
|
||||||
_NAV_ROW_GAP = 6
|
_NAV_ROW_GAP = 6
|
||||||
_NAV_MIN_WIDTH = 132
|
_NAV_MIN_WIDTH = 54
|
||||||
_NAV_MAX_SHARE = 0.22
|
_NAV_MAX_SHARE = 0.22
|
||||||
_NAV_MAX_CEILING = 360
|
_NAV_MAX_CEILING = 360
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user