Skip to content

Commit

Permalink
Merge pull request #2567 from davep/issue/2557/select-update
Browse files Browse the repository at this point in the history
Fix clearing an OptionList
  • Loading branch information
davep authored May 16, 2023
2 parents faa67a8 + 1ebfe2f commit 83e4be7
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,17 @@ def clear_options(self) -> Self:
"""
self._contents.clear()
self._options.clear()
self._refresh_content_tracking(force=True)
self.highlighted = None
self._mouse_hovering_over = None
self.virtual_size = Size(self.scrollable_content_region.width, 0)
self.refresh()
# TODO: See https://github.com/Textualize/textual/issues/2582 -- it
# should not be necessary to do this like this here; ideally here in
# clear_options it would be a forced refresh, and also in a
# `on_show` it would be the same (which, I think, would actually
# solve the problem we're seeing). But, until such a time as we get
# to the bottom of 2582... this seems to delay the refresh enough
# that things fall into place.
self._request_content_tracking_refresh()
return self

def _set_option_disabled(self, index: int, disabled: bool) -> Self:
Expand Down
Loading

0 comments on commit 83e4be7

Please sign in to comment.