File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,21 @@ def _add_component_from_item(self, item: Item):
9191
9292 def _set_components (self , items : list [Item ]):
9393 self ._underlying .components .clear ()
94- if not any (isinstance (b , Select ) for b in self .children ):
94+ for item in items :
95+ self ._add_component_from_item (item )
96+
97+ def _reorder (self ):
98+ items = self .children
99+ if not any ([isinstance (b , Select ) for b in self .children ]):
95100 a , b = [], []
96101 for i in items :
97102 if i .priority is None :
98103 b .append (i )
99104 else :
100105 a .append (i )
101- items = sorted (a , key = lambda b : b .priority ) + b
102- for item in items :
103- self ._add_component_from_item ( item )
106+ items = sorted (a , key = lambda c : c .priority ) + b
107+ self . children = items
108+ self ._set_components ( items )
104109
105110 def add_item (self , item : Item ) -> Self :
106111 """Adds an item to the action row.
@@ -350,7 +355,7 @@ def walk_items(self) -> Iterator[Item]:
350355 yield from self .children
351356
352357 def to_component_dict (self ) -> ActionRowPayload :
353- self ._set_components ( self . children )
358+ self ._reorder ( )
354359 return self ._underlying .to_dict ()
355360
356361 @classmethod
You can’t perform that action at this time.
0 commit comments