Skip to content

Commit

Permalink
Fix move_child noop when target is child.
Browse files Browse the repository at this point in the history
This finishes the work done in #2530, which was incomplete as seen in #1743 (comment).
  • Loading branch information
rodrigogiraoserrao committed Dec 18, 2023
1 parent be86237 commit a9444aa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,10 +941,6 @@ def move_child(
elif before is not None and after is not None:
raise WidgetError("Only one of `before` or `after` can be handled.")

# We short-circuit the no-op, otherwise it will error later down the road.
if child is before or child is after:
return

def _to_widget(child: int | Widget, called: str) -> Widget:
"""Ensure a given child reference is a Widget."""
if isinstance(child, int):
Expand All @@ -969,6 +965,9 @@ def _to_widget(child: int | Widget, called: str) -> Widget:
cast("int | Widget", before if after is None else after), "move towards"
)

if child is target:
return # Nothing to be done.

# At this point we should know what we're moving, and it should be a
# child; where we're moving it to, which should be within the child
# list; and how we're supposed to move it. All that's left is doing
Expand Down

0 comments on commit a9444aa

Please sign in to comment.