[FIXED] Flow Panel add component at index doesn't seem to work

What I’m trying to do:
Trying to add_component in FlowPanel from code at a specified index

What I’ve tried and what’s not working:

Code Sample:

    self.flow_panel_1.add_component(Label(text="two"),index=2)
    self.flow_panel_1.add_component(Label(text="zero"),index=0)
    self.flow_panel_1.add_component(Label(text="one"),index=1)

Desired Output
zero one two initial

Produced Output
image

Clone link:
https://anvil.works/build#clone:LP2I4C4IN55HLTPW=THYDVYQ6TO4RQBXUSWQ3IHNN

Am I doing it wrong or is it a bug?

When you try to insert the first one (“two”) at index 2, there is no index 2. I wonder whether that is causing the issue? If you only use indexes that make sense at the time of insertion, does it work then?

1 Like
    self.flow_panel_1.add_component(Label(text="two"),index=0)
    self.flow_panel_1.add_component(Label(text="one"),index=0)
    self.flow_panel_1.add_component(Label(text="zero"),index=0)

Expected Output: zero one two initial
Actual Output: initial two one zero

1 Like

Thanks for the clone link - the behaviour should work as @hugetim described.

There’s a bug in the implementation, and this should be fixed soon.

2 Likes

that should now be fixed

2 Likes

5 posts were split to a new topic: Working with global variables