diff --git a/CHANGELOG.md b/CHANGELOG.md index 669fdffde5..0b05c58aae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Updated the tutorial (text and code) https://github.com/Textualize/textual/pull/5257 +- The Select widget no longer scrolls it's container when expanded https://github.com/Textualize/textual/pull/5265 ### Fixed diff --git a/src/textual/widgets/_select.py b/src/textual/widgets/_select.py index 8d651cbe44..7fe22fe407 100644 --- a/src/textual/widgets/_select.py +++ b/src/textual/widgets/_select.py @@ -214,7 +214,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True): & > SelectOverlay { width: 1fr; - display: none; + visibility: hidden; height: auto; max-height: 12; overlay: screen; @@ -240,7 +240,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True): } & > SelectOverlay { - display: block; + visibility: visible; } } @@ -503,17 +503,18 @@ def _watch_expanded(self, expanded: bool) -> None: return self.set_class(expanded, "-expanded") if expanded: - overlay.focus() + select_current = self.query_one(SelectCurrent) + overlay.focus(scroll_visible=False) if self.value is self.BLANK: overlay.select(None) - self.query_one(SelectCurrent).has_value = False + select_current.has_value = False else: value = self.value for index, (_prompt, prompt_value) in enumerate(self._options): if value == prompt_value: overlay.select(index) break - self.query_one(SelectCurrent).has_value = True + select_current.has_value = True @on(SelectCurrent.Toggle) def _select_current_toggle(self, event: SelectCurrent.Toggle) -> None: