mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
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.
This commit is contained in:
@@ -116,20 +116,13 @@ class SelectionList(Generic[SelectionType], OptionList):
|
|||||||
disabled: Whether the selection list is disabled or not.
|
disabled: Whether the selection list is disabled or not.
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
*[self._make_selection(selection) for selection in selections],
|
||||||
name=name,
|
name=name,
|
||||||
id=id,
|
id=id,
|
||||||
classes=classes,
|
classes=classes,
|
||||||
disabled=disabled,
|
disabled=disabled,
|
||||||
)
|
)
|
||||||
self._selected: dict[SelectionType, None] = {}
|
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(
|
def _make_selection(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user