Skip to content

Commit

Permalink
skip invisible widgets, update lines on mount for option list
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Feb 11, 2025
1 parent 956d756 commit 72b8bfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,6 @@ def _scroll_to(
Returns:
`True` if the scroll position changed, otherwise `False`.
"""

maybe_scroll_x = x is not None and (self.allow_horizontal_scroll or force)
maybe_scroll_y = y is not None and (self.allow_vertical_scroll or force)
scrolled_x = scrolled_y = False
Expand Down Expand Up @@ -3200,6 +3199,9 @@ def scroll_to_widget(
region = widget.virtual_region_with_margin
scrolled = False

if not region.size:
return False

while isinstance(widget.parent, Widget) and widget is not self:
container = widget.parent
if widget.styles.dock != "none":
Expand Down
3 changes: 3 additions & 0 deletions src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ def _on_resize(self):
def on_show(self) -> None:
self.scroll_to_highlight()

def on_mount(self) -> None:
self._update_lines()

async def _on_click(self, event: events.Click) -> None:
"""React to the mouse being clicked on an item.
Expand Down

0 comments on commit 72b8bfe

Please sign in to comment.