Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions src/textual/widgets/_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -240,7 +240,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True):
}

& > SelectOverlay {
display: block;
visibility: visible;
}
}

Expand Down Expand Up @@ -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:
Expand Down
Loading