Skip to content

Commit 3b8713b

Browse files
authored
Merge pull request #5730 from TomJGooding/fix-option-list-fix-size-when-options-removed
fix(option list): fix size when options removed or cleared
2 parents 95ed58a + 4a27e48 commit 3b8713b

File tree

5 files changed

+352
-3
lines changed

5 files changed

+352
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Fixed markup escaping edge cases https://github.com/Textualize/textual/pull/5697
1313
- Fixed incorrect auto height in Collapsible https://github.com/Textualize/textual/pull/5703
1414
- Fixed issue with keymaps and single-letter keys https://github.com/Textualize/textual/pull/5726
15+
- Fixed `OptionList` size after removing or clearing options https://github.com/Textualize/textual/issues/5728
1516
- Fixed footer / key panel not updating when keymaps are applied https://github.com/Textualize/textual/pull/5724
1617
- Fixed alignment not being applied when there are min and max limits on dimensions https://github.com/Textualize/textual/pull/5732
1718

src/textual/widgets/_option_list.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def _remove_option(self, option: Option) -> Self:
534534
del self._id_to_option[option._id]
535535
del self._option_to_index[option]
536536
self.highlighted = self.highlighted
537-
self.refresh()
537+
self._clear_caches()
538538
return self
539539

540540
def _pre_remove_option(self, option: Option, index: int) -> None:
@@ -759,8 +759,7 @@ def _get_option_render(self, option: Option, style: Style) -> list[Strip]:
759759

760760
def _update_lines(self) -> None:
761761
"""Update internal structures when new lines are added."""
762-
if not self.options or not self.scrollable_content_region:
763-
# No options -- nothing to
762+
if not self.scrollable_content_region:
764763
return
765764

766765
line_cache = self._line_cache
Lines changed: 154 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)