File tree Expand file tree Collapse file tree 4 files changed +185
-11
lines changed
__snapshots__/test_snapshots Expand file tree Collapse file tree 4 files changed +185
-11
lines changed Original file line number Diff line number Diff line change @@ -614,9 +614,8 @@ def add_widget(
614614 - widget .scrollbar_size_horizontal
615615 )
616616 )
617- capped_scroll_y = widget .validate_scroll_y (new_scroll_y )
618- widget .set_reactive (Widget .scroll_y , capped_scroll_y )
619- widget .set_reactive (Widget .scroll_target_y , capped_scroll_y )
617+ widget .set_reactive (Widget .scroll_y , new_scroll_y )
618+ widget .set_reactive (Widget .scroll_target_y , new_scroll_y )
620619 widget .vertical_scrollbar ._reactive_position = new_scroll_y
621620
622621 if visible_only :
Original file line number Diff line number Diff line change @@ -4274,9 +4274,7 @@ def remove_children(
42744274 ]
42754275 else :
42764276 children_to_remove = selector
4277- await_remove = self .app ._prune (
4278- * children_to_remove , parent = cast (DOMNode , self ._parent )
4279- )
4277+ await_remove = self .app ._prune (* children_to_remove , parent = self )
42804278 return await_remove
42814279
42824280 @asynccontextmanager
@@ -4423,11 +4421,12 @@ def _check_refresh(self) -> None:
44234421 self .call_later (self ._update_styles )
44244422 if self ._scroll_required :
44254423 self ._scroll_required = False
4426- if self .styles .keyline [0 ] != "none" :
4427- # TODO: Feels like a hack
4428- # Perhaps there should be an explicit mechanism for backgrounds to refresh when scrolled?
4429- self ._set_dirty ()
4430- screen .post_message (messages .UpdateScroll ())
4424+ if not self ._layout_required :
4425+ if self .styles .keyline [0 ] != "none" :
4426+ # TODO: Feels like a hack
4427+ # Perhaps there should be an explicit mechanism for backgrounds to refresh when scrolled?
4428+ self ._set_dirty ()
4429+ screen .post_message (messages .UpdateScroll ())
44314430 if self ._repaint_required :
44324431 self ._repaint_required = False
44334432 if self .display :
Original file line number Diff line number Diff line change @@ -4713,3 +4713,29 @@ def compose(self) -> ComposeResult:
47134713 yield Static ("Hello, World! 293487 " * 200 )
47144714
47154715 assert snap_compare (ScrollbarApp ())
4716+
4717+
4718+ def test_prune_fix (snap_compare ) -> None :
4719+ """Regression test for https://github.com/Textualize/textual/issues/6205
4720+
4721+ You should see the text "Hello" and "World" across the first two lines.
4722+ The original issue is that a layout operation wasn't done after removing children, leaving
4723+ a large gap between "Hello" and "World"
4724+
4725+ """
4726+
4727+ class PruneApp (App ):
4728+ BINDINGS = [Binding ("c" , "clear" , priority = True )]
4729+
4730+ def compose (self ) -> ComposeResult :
4731+ yield Static ("Hello" )
4732+ with VerticalGroup ():
4733+ for i in range (10 ):
4734+ yield Static (str (i ))
4735+ yield Static ("World" )
4736+
4737+ async def action_clear (self ) -> None :
4738+ vs = self .query_one (VerticalGroup )
4739+ await vs .remove_children ()
4740+
4741+ assert snap_compare (PruneApp (), press = ["c" ])
You can’t perform that action at this time.
0 commit comments