mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Using `Widget.move_child` where the target and the child being moved are the same is now a no-op https://github.com/Textualize/textual/issues/1743
|
||||||
|
|
||||||
## [0.24.1] - 2023-05-08
|
## [0.24.1] - 2023-05-08
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -795,19 +795,15 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
child: The child widget to move.
|
child: The child widget to move.
|
||||||
before: Optional location to move before. An `int` is the index
|
before: Child widget or location index to move before.
|
||||||
of the child to move before, a `str` is a `query_one` query to
|
after: Child widget or location index to move after.
|
||||||
find the widget to move before.
|
|
||||||
after: Optional location to move after. An `int` is the index
|
|
||||||
of the child to move after, a `str` is a `query_one` query to
|
|
||||||
find the widget to move after.
|
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
WidgetError: If there is a problem with the child or target.
|
WidgetError: If there is a problem with the child or target.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
Only one of ``before`` or ``after`` can be provided. If neither
|
Only one of `before` or `after` can be provided. If neither
|
||||||
or both are provided a ``WidgetError`` will be raised.
|
or both are provided a `WidgetError` will be raised.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# One or the other of before or after are required. Can't do
|
# One or the other of before or after are required. Can't do
|
||||||
@@ -817,6 +813,9 @@ class Widget(DOMNode):
|
|||||||
elif before is not None and after is not None:
|
elif before is not None and after is not None:
|
||||||
raise WidgetError("Only one of `before` or `after` can be handled.")
|
raise WidgetError("Only one of `before` or `after` can be handled.")
|
||||||
|
|
||||||
|
if child is before or child is after:
|
||||||
|
return
|
||||||
|
|
||||||
def _to_widget(child: int | Widget, called: str) -> Widget:
|
def _to_widget(child: int | Widget, called: str) -> Widget:
|
||||||
"""Ensure a given child reference is a Widget."""
|
"""Ensure a given child reference is a Widget."""
|
||||||
if isinstance(child, int):
|
if isinstance(child, int):
|
||||||
|
|||||||
@@ -42,22 +42,18 @@ async def test_move_child_to_outside() -> None:
|
|||||||
pilot.app.screen.move_child(child, before=Widget())
|
pilot.app.screen.move_child(child, before=Widget())
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(
|
|
||||||
strict=True, reason="https://github.com/Textualize/textual/issues/1743"
|
|
||||||
)
|
|
||||||
async def test_move_child_before_itself() -> None:
|
async def test_move_child_before_itself() -> None:
|
||||||
"""Test moving a widget before itself."""
|
"""Test moving a widget before itself."""
|
||||||
|
|
||||||
async with App().run_test() as pilot:
|
async with App().run_test() as pilot:
|
||||||
child = Widget(Widget())
|
child = Widget(Widget())
|
||||||
await pilot.app.mount(child)
|
await pilot.app.mount(child)
|
||||||
pilot.app.screen.move_child(child, before=child)
|
pilot.app.screen.move_child(child, before=child)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(
|
|
||||||
strict=True, reason="https://github.com/Textualize/textual/issues/1743"
|
|
||||||
)
|
|
||||||
async def test_move_child_after_itself() -> None:
|
async def test_move_child_after_itself() -> None:
|
||||||
"""Test moving a widget after itself."""
|
"""Test moving a widget after itself."""
|
||||||
|
# Regression test for https://github.com/Textualize/textual/issues/1743
|
||||||
async with App().run_test() as pilot:
|
async with App().run_test() as pilot:
|
||||||
child = Widget(Widget())
|
child = Widget(Widget())
|
||||||
await pilot.app.mount(child)
|
await pilot.app.mount(child)
|
||||||
|
|||||||
Reference in New Issue
Block a user