nicedouble / StreamlitAntdComponents

A Streamlit component to display Antd-Design
https://nicedouble-streamlitantdcomponentsdemo-app-middmy.streamlit.app/
MIT License
442 stars 29 forks source link

Cascader return results in random order #67

Open rsheftel opened 3 months ago

rsheftel commented 3 months ago

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"]