mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Ensure the pressed button index is correct in the message
At the time that we're raising RadioSet.Changed, we can't be sure that the class updates and the like have finished post RadioButton.watch_value happening; this means that the "public" route to getting the pressed index could be wrong (or rather, not quite up to date yet). Meanwhile, here, we know the button involved, so we go looking for its index directly.
This commit is contained in:
@@ -87,7 +87,12 @@ class RadioSet(Container):
|
||||
"""A reference to the `RadioSet` that was changed."""
|
||||
self.pressed = pressed
|
||||
"""The `RadioButton` that was pressed to make the change."""
|
||||
self.index = sender.pressed_index
|
||||
# Note: it would be cleaner to use `sender.pressed_index` here,
|
||||
# but we can't be 100% sure all of the updates have happened at
|
||||
# this point, and so we can't go looking for the index of the
|
||||
# pressed button via the normal route. So here we go under the
|
||||
# hood.
|
||||
self.index = sender._nodes.index(pressed)
|
||||
"""The index of the `RadioButton` that was pressed to make the change."""
|
||||
|
||||
def on_radio_button_changed(self, event: RadioButton.Changed) -> None:
|
||||
|
||||
Reference in New Issue
Block a user