From bc126ce03677f2b80d367a5907aa71111d0f2895 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 18 May 2023 16:20:32 +0100 Subject: [PATCH] Build the selection list back in __init__ again Now that I'm no longer having to dodge issues with getting component classes before the DOM has spun up, I can go back to the simpler method of setting up the selections. This also means I can drop Mount handling. --- src/textual/widgets/_selection_list.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/textual/widgets/_selection_list.py b/src/textual/widgets/_selection_list.py index fc59b3c4a..c6a79611b 100644 --- a/src/textual/widgets/_selection_list.py +++ b/src/textual/widgets/_selection_list.py @@ -116,20 +116,13 @@ class SelectionList(Generic[SelectionType], OptionList): disabled: Whether the selection list is disabled or not. """ super().__init__( + *[self._make_selection(selection) for selection in selections], name=name, id=id, classes=classes, disabled=disabled, ) self._selected: dict[SelectionType, None] = {} - self._selections = selections - - def _on_mount(self): - self.add_options( - [self._make_selection(selection) for selection in self._selections] - ) - if self.option_count: - self.highlighted = 0 def _make_selection( self,