Skip to content

Commit

Permalink
Ensure reflow reflows non-visible widgets, fix scroll_to_center issue (
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns authored May 29, 2023
1 parent 6cb052a commit a40300a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fixed zero division error https://github.com/Textualize/textual/issues/2673
- 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

### Added

Expand Down
6 changes: 3 additions & 3 deletions src/textual/_compositor.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ class Compositor:

def __init__(self) -> None:
# A mapping of Widget on to its "render location" (absolute position / depth)

self._full_map: CompositorMap = {}
self._full_map_invalidated = True
self._visible_map: CompositorMap | None = None
Expand Down Expand Up @@ -358,7 +357,7 @@ def reflow(self, parent: Widget, size: Size) -> ReflowResult:
old_map = self._full_map
old_widgets = old_map.keys()

map, widgets = self._arrange_root(parent, size)
map, widgets = self._arrange_root(parent, size, visible_only=False)

new_widgets = map.keys()

Expand Down Expand Up @@ -1021,11 +1020,12 @@ def __rich__(self) -> StripRenderable:
return StripRenderable(self.render_strips())

def update_widgets(self, widgets: set[Widget]) -> None:
"""Update a given widget in the composition.
"""Update the given widgets in the composition.
Args:
widgets: Set of Widgets to update.
"""

# If there are any *new* widgets we need to invalidate the full map
if not self._full_map_invalidated and not widgets.issubset(
self.visible_widgets.keys()
Expand Down
Loading

0 comments on commit a40300a

Please sign in to comment.