Skip to content

Commit a40300a

Browse files
authored
Ensure reflow reflows non-visible widgets, fix scroll_to_center issue (#2684)
1 parent 6cb052a commit a40300a

File tree

5 files changed

+81
-79
lines changed

5 files changed

+81
-79
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111
### Fixed
1212

1313
- Fixed zero division error https://github.com/Textualize/textual/issues/2673
14+
- Fix `scroll_to_center` when there were nested layers out of view (Compositor full_map not populated fully) https://github.com/Textualize/textual/pull/2684
1415

1516
### Added
1617

src/textual/_compositor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ class Compositor:
266266

267267
def __init__(self) -> None:
268268
# A mapping of Widget on to its "render location" (absolute position / depth)
269-
270269
self._full_map: CompositorMap = {}
271270
self._full_map_invalidated = True
272271
self._visible_map: CompositorMap | None = None
@@ -358,7 +357,7 @@ def reflow(self, parent: Widget, size: Size) -> ReflowResult:
358357
old_map = self._full_map
359358
old_widgets = old_map.keys()
360359

361-
map, widgets = self._arrange_root(parent, size)
360+
map, widgets = self._arrange_root(parent, size, visible_only=False)
362361

363362
new_widgets = map.keys()
364363

@@ -1021,11 +1020,12 @@ def __rich__(self) -> StripRenderable:
10211020
return StripRenderable(self.render_strips())
10221021

10231022
def update_widgets(self, widgets: set[Widget]) -> None:
1024-
"""Update a given widget in the composition.
1023+
"""Update the given widgets in the composition.
10251024
10261025
Args:
10271026
widgets: Set of Widgets to update.
10281027
"""
1028+
10291029
# If there are any *new* widgets we need to invalidate the full map
10301030
if not self._full_map_invalidated and not widgets.issubset(
10311031
self.visible_widgets.keys()

0 commit comments

Comments
 (0)