File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 1313from .section import Section
1414from .separator import Separator
1515from .text_display import TextDisplay
16+ from .view import _walk_all_components
1617
1718__all__ = ("Container" ,)
1819
@@ -58,21 +59,16 @@ def __init__(
5859 super ().__init__ ()
5960
6061 self .items = [i for i in items ]
62+ components = [i ._underlying for i in items ]
6163 self ._color = colour
6264
6365 self ._underlying = ContainerComponent ._raw_construct (
6466 type = ComponentType .container ,
6567 id = None ,
66- components = [] ,
68+ components = components ,
6769 accent_color = colour ,
6870 spoiler = spoiler ,
6971 )
70- for i in items :
71- if isinstance (i , ActionRow ):
72- for c in i .children :
73- self .add_item (c )
74- else :
75- self .add_item (i )
7672
7773 def add_item (self , item : Item ) -> None :
7874 """Adds an item to the container.
@@ -243,7 +239,7 @@ def to_component_dict(self) -> ContainerComponentPayload:
243239 def from_component (cls : type [C ], component : ContainerComponent ) -> C :
244240 from .view import _component_to_item
245241
246- items = [_component_to_item (c ) for c in component .components ]
242+ items = [_component_to_item (c ) for c in _walk_all_components ( component .components ) ]
247243 return cls (* items , colour = component .accent_color , spoiler = component .spoiler )
248244
249245 callback = None
Original file line number Diff line number Diff line change 4949from ..utils import get
5050from .item import Item , ItemCallbackType
5151
52- __all__ = ("View" , "_component_to_item" )
52+ __all__ = ("View" , "_component_to_item" , "_walk_all_components" )
5353
5454
5555if TYPE_CHECKING :
@@ -104,7 +104,7 @@ def _component_to_item(component: Component) -> Item:
104104 from .container import Container
105105
106106 return Container .from_component (component )
107- if isinstance (component , ActionRow ):
107+ if isinstance (component , ActionRowComponent ):
108108 # Handle ActionRow.children manually, or design ui.ActionRow?
109109
110110 return component
You can’t perform that action at this time.
0 commit comments