Skip to content

Commit 9f19f5f

Browse files
authored
Merge pull request #5290 from Textualize/fix-anchor
fix anchor
2 parents 6f1f753 + be1156a commit 9f19f5f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
### Unreleased
9+
10+
### Fixed
11+
12+
- Fixed infinite loop in `Widget.anchor` https://github.com/Textualize/textual/pull/5290
13+
814
## [0.87.1] - 2024-11-24
915

1016
## Fixed

src/textual/widget.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def opacity(self) -> float:
593593
@property
594594
def is_anchored(self) -> bool:
595595
"""Is this widget anchored?"""
596-
return self._parent is not None and self._parent is self
596+
return isinstance(self._parent, Widget) and self._parent._anchored is self
597597

598598
@property
599599
def is_mouse_over(self) -> bool:
@@ -4080,9 +4080,7 @@ async def _on_idle(self, event: events.Idle) -> None:
40804080
self._check_refresh()
40814081

40824082
if self.is_anchored:
4083-
self.scroll_visible(animate=self._anchor_animate)
4084-
if self._anchored:
4085-
self._anchored.scroll_visible(animate=self._anchor_animate)
4083+
self.scroll_visible(animate=self._anchor_animate, immediate=True)
40864084

40874085
def _check_refresh(self) -> None:
40884086
"""Check if a refresh was requested."""

0 commit comments

Comments
 (0)