Fix nested UI item parent state

This commit is contained in:
harumaki4649
2026-07-10 19:37:41 -04:00
committed by GitHub
parent f6dbb848d0
commit d2996be144
5 changed files with 113 additions and 0 deletions
+6
View File
@@ -203,6 +203,9 @@ class ActionRow(Item[V]):
def _swap_item(self, base: Item, new: DynamicItem, custom_id: str) -> None:
child_index = self._children.index(base)
self._children[child_index] = new # type: ignore
base._detach_view()
new._update_view(self.view)
new._parent = self
@property
def width(self):
@@ -299,6 +302,7 @@ class ActionRow(Item[V]):
if self._view:
self._view._add_count(-1)
self._weight -= item.width
item._detach_view()
return self
@@ -330,6 +334,8 @@ class ActionRow(Item[V]):
"""
if self._view:
self._view._add_count(-len(self._children))
for item in self._children:
item._detach_view()
self._children.clear()
self._weight = 0
return self