From 74bbf1a8131df1924f6f0c85fd5e5bd08512ee50 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Tue, 3 Dec 2024 11:53:21 +0000 Subject: [PATCH] fix selection list breakage --- src/textual/widgets/_selection_list.py | 3 ++- tests/snapshot_tests/test_snapshots.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/textual/widgets/_selection_list.py b/src/textual/widgets/_selection_list.py index 7493990f2e..1d147377cf 100644 --- a/src/textual/widgets/_selection_list.py +++ b/src/textual/widgets/_selection_list.py @@ -50,7 +50,8 @@ def __init__( disabled: The initial enabled/disabled state. Enabled by default. """ if isinstance(prompt, str): - prompt = Text.from_markup(prompt) + prompt = Text.from_markup(prompt, overflow="ellipsis") + prompt.no_wrap = True super().__init__(prompt.split()[0], id, disabled) self._value: SelectionType = value """The value associated with the selection.""" diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 10fffd49c9..0c18b4e42d 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -2878,3 +2878,13 @@ def check_action( return True snap_compare(FooterApp()) + + +def test_selection_list_wrap(snap_compare): + """Regression test for https://github.com/Textualize/textual/issues/5326""" + + class SelectionListApp(App): + def compose(self) -> ComposeResult: + yield SelectionList(("Hello World " * 100, 0)) + + snap_compare(SelectionListApp())