nicedouble / StreamlitAntdComponents

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

Menu: Index not returned for parent of group #15

Open feelancer21 opened 1 year ago

feelancer21 commented 1 year ago

Awesome project :partying_face:

I am exploring the component with the following example

with st.sidebar:    
    item1 = sac.menu([
            sac.MenuItem('home', icon='house', tag='Tag', children=[
                sac.MenuItem('store', icon='bag-check'),
                sac.MenuItem('brand', icon='award', children=[
                    sac.MenuItem('github', icon='github'),
                    sac.MenuItem('apple', icon='apple'),
                ]),
            ])
        ], open_all=True, return_index=True)

st.write(f'The selected menu item : {item1}')

When I select 'store' then item1 = 1, for 'github' I get item1 = 3. But when I select 'brand', item1 keeps unchanged, but I expect item1 = 2.

CHerSun commented 1 year ago

groups are not selectable in most hierarchical menus, including this one. Click on a group just expands its children, but doesn't really select it. So, imo, works as expected.

CHerSun commented 1 year ago

Btw, Tree allows parent selection, maybe you were looking for that option.