Fixed item state management in the UI View

* Fix ActionRow add_item type validation
* Fix View item state tracking
* Fix View add and remove item state
* Add UI view item state tests
This commit is contained in:
harumaki4649
2026-07-08 16:14:41 -04:00
committed by GitHub
parent f9c66a6a38
commit cc00d56a22
3 changed files with 97 additions and 11 deletions
+3 -3
View File
@@ -260,15 +260,15 @@ class ActionRow(Item[V]):
or (40) for the entire view.
"""
if not isinstance(item, Item):
raise TypeError(f'expected Item not {item.__class__.__name__}')
if (self._weight + item.width) > 5:
raise ValueError('maximum number of children exceeded')
if len(self._children) >= 5:
raise ValueError('maximum number of children exceeded')
if not isinstance(item, Item):
raise TypeError(f'expected Item not {item.__class__.__name__}')
if self._view:
self._view._add_count(1)