StreamlitAntdComponents icon indicating copy to clipboard operation
StreamlitAntdComponents copied to clipboard

Cascader return results in random order

Open rsheftel opened this issue 1 year ago • 1 comments

First thank you very much for this excellent library. I am using the cascader component with options of multiple=False and other other options the default. When I use it with two items the return list is in the correct order, but when I add the third item, the order of the list of returned items becomes random such that there is no way to map the return items list to the initial options.

Here is an example. If we run this code

import streamlit as st
from streamlit_antd_components import CasItem, cascader

items = [
    CasItem(
        "first",
        children=[CasItem("US", children=[CasItem("second", children=[CasItem("inter1", children=[CasItem("final1")])]),
                                          CasItem("third", children=[CasItem("inter2", children=[CasItem("final2")])]),
                                          CasItem("forth", children=[CasItem("inter3", children=[CasItem("final3")])]),
                                          CasItem("fifth", children=[CasItem("inter4", children=[CasItem("final4")])]),
                                          CasItem("sixth", children=[CasItem("inter5", children=[CasItem("final5")])])
                                          ],
                          )
                  ],
    ),
]

result = cascader(items, multiple=False)
st.write(result)

And then select the following from the cascader:

image

The return list is in the order

["first", "US", "final3", "forth", "inter3"]

When I would have expected the order of the result to be consistent with the display of the cascader:

["first", "US", "forth", "inter3", "final3"]

rsheftel avatar Aug 28 '24 19:08 rsheftel

I have the same problem.

MelikbekyanAshot avatar Jan 15 '25 07:01 MelikbekyanAshot