Skip to content

Commit 944d6cc

Browse files
authored
Merge pull request #5736 from Textualize/scrollbar-refresh
fix scrollbar refresh issue
2 parents 1442a96 + d7641d9 commit 944d6cc

10 files changed

+319
-316
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Fixed `OptionList` size after removing or clearing options https://github.com/Textualize/textual/issues/5728
1616
- Fixed footer / key panel not updating when keymaps are applied https://github.com/Textualize/textual/pull/5724
1717
- Fixed alignment not being applied when there are min and max limits on dimensions https://github.com/Textualize/textual/pull/5732
18+
- Fixed issues with OptionList scrollbar not updating https://github.com/Textualize/textual/pull/5736
1819

1920
### Changed
2021

2122
- Collapsible title now accepts str, Text, or Content https://github.com/Textualize/textual/pull/5697
2223
- Rich Text objects will be converted to Content in OptionList and other widgets https://github.com/Textualize/textual/pull/5712
2324
- Textual will always convert dim attributes to RGB by default https://github.com/Textualize/textual/pull/5715
24-
- Notifications will now use Textual markup (previously they used Console markup) https://github.com/Textualize/textual/pull/5719
25+
- Notifications will now use content markup (previously they used Console markup) https://github.com/Textualize/textual/pull/5719
2526

2627
### Added
2728

src/textual/widget.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,13 +3873,11 @@ def _scroll_update(self, virtual_size: Size) -> None:
38733873
self.vertical_scrollbar.window_size = (
38743874
height - self.scrollbar_size_horizontal
38753875
)
3876-
if self.vertical_scrollbar._repaint_required:
3877-
self.vertical_scrollbar.refresh()
3876+
self.vertical_scrollbar.refresh()
38783877
if self.show_horizontal_scrollbar:
38793878
self.horizontal_scrollbar.window_virtual_size = virtual_size.width
38803879
self.horizontal_scrollbar.window_size = width - self.scrollbar_size_vertical
3881-
if self.horizontal_scrollbar._repaint_required:
3882-
self.horizontal_scrollbar.refresh()
3880+
self.horizontal_scrollbar.refresh()
38833881

38843882
self.scroll_x = self.validate_scroll_x(self.scroll_x)
38853883
self.scroll_y = self.validate_scroll_y(self.scroll_y)

src/textual/widgets/_option_list.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ def clear_options(self) -> Self:
311311
self._option_to_index.clear()
312312
self.highlighted = None
313313
self.refresh()
314+
self.scroll_to(0, 0, animate=False)
315+
self._update_lines()
314316
return self
315317

316318
def add_options(self, new_options: Iterable[OptionListContent]) -> Self:

tests/snapshot_tests/__snapshots__/test_snapshots/test_auto_height_scrollbar.svg

Lines changed: 59 additions & 59 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_enforce_visual.svg

Lines changed: 1 addition & 1 deletion
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_loading_indicator_disables_widget.svg

Lines changed: 4 additions & 3 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_max_height_100.svg

Lines changed: 58 additions & 58 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_missing_vertical_scroll.svg

Lines changed: 62 additions & 61 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_option_list_options.svg

Lines changed: 64 additions & 64 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_option_list_tables.svg

Lines changed: 65 additions & 65 deletions
Loading

0 commit comments

Comments
 (0)