Skip to content

Commit

Permalink
Merge pull request #5420 from Textualize/select-update
Browse files Browse the repository at this point in the history
Select update
  • Loading branch information
willmcgugan authored Dec 21, 2024
2 parents 2fb527b + 206d70d commit d34f4a4
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fixed `Pilot.click` not working with `times` parameter https://github.com/Textualize/textual/pull/5398
- Fixed select refocusing itself too late https://github.com/Textualize/textual/pull/5420

### Added

Expand Down
10 changes: 3 additions & 7 deletions src/textual/widgets/_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def _watch_expanded(self, expanded: bool) -> None:
value = self.value
for index, (_prompt, prompt_value) in enumerate(self._options):
if value == prompt_value:
self.call_after_refresh(overlay.select, index)
overlay.select(index)
break
self.query_one(SelectCurrent).has_value = True

Expand All @@ -637,12 +637,8 @@ def _update_selection(self, event: SelectOverlay.UpdateSelection) -> None:
if value != self.value:
self.value = value

async def update_focus() -> None:
"""Update focus and reset overlay."""
self.focus()
self.expanded = False

self.call_after_refresh(update_focus) # Prevents a little flicker
self.focus()
self.expanded = False

def action_show_overlay(self) -> None:
"""Show the overlay."""
Expand Down
Loading

0 comments on commit d34f4a4

Please sign in to comment.