diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ef7ca7302..7245bc3a27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fixed issues in Kitty terminal after exiting app https://github.com/Textualize/textual/issues/4779 +- Fixed exception when removing Selects ## [0.73.0] - 2024-07-18 diff --git a/tests/select/test_remove.py b/tests/select/test_remove.py new file mode 100644 index 0000000000..989884a8c9 --- /dev/null +++ b/tests/select/test_remove.py @@ -0,0 +1,25 @@ +from textual.app import App, ComposeResult +from textual.widgets import Header, Select + +LINES = """I must not fear. +Fear is the mind-killer. +Fear is the little-death that brings total obliteration. +I will face my fear. +I will permit it to pass over me and through me.""".splitlines() + + +async def test_select_remove(): + # Regression test for https://github.com/Textualize/textual/issues/4782 + class SelectApp(App): + def compose(self) -> ComposeResult: + self.select = Select((line, line) for line in LINES) + self.select.watch_value = self.on_select + yield Header() + yield self.select + + def on_select(self): + self.select.remove() + + app = SelectApp() + async with app.run_test() as pilot: + await pilot.press("enter", "down", "down", "enter")