St.chat_input interaction with other menu option component


Odd behvaiour with the st.chat_input and the streamlit option menu. The menu option flicks back to the original choice although the page remains changed. See code below to reproduce the result. Any help resolving this would be great. Note that the option menu works fine with st.text_input but when I swap it for st.chat_input the issue arises with the conditional β€œif” block.

Steps to reproduce

import streamlit as st
from streamlit_option_menu import option_menu

def main():
    #st.set_option('deprecation.showPyplotGlobalUse', False)

    # menu for document analyzer apps
    summary_type = option_menu(
        options=["Q&A", "Summarization", "Compare & Contrast", "Output Parsers", "Admin Panel"],

    if summary_type == "Q&A":
        st.markdown("Page 1")
        st.chat_input("Enter your message here")
if __name__ == "__main__":

Hi ddealwis09,
It working fine :white_check_mark: when I execute the same code that you provided

Hi Vicky,
You mean the menu option isn’t flicking back to the original option being selected? I have a video recording of it but I’m not sure how to upload it to streamlit to show…

Yes, while click on the summary button the option flicks and highlighting the Q&A option but showing the summary under the option. You can upload the video on the google drive and share the link here.

Here is the video illustrating the issue. Can anyone help?

So you do agree there is an issue correct?

Can you please make the video view from private to public, or you need to give the access manually.


Hi, I’ve now made it public, the link should work.

Can this be resolved with st.session_state ??

Unfortunately, I have the same problem … Did anyone find a solution?

There is a bug in the component, we are going to submit a pull request in the coming weeks, not sure if it’s being maintained however.

1 Like

I had the same problem, I could not find any solution I finally used st.session to change the default_index value. I’m not sure how good is my method but it worked for my situation

if 'menu_option' not in st.session_state:
       st.session_state['menu_option'] =[0,0]
selected_tab= option_menu(
            default_index=st.session_state['menu_option'][1] , 

if selected_tab=="1":

if selected_tab=="2":

if st.session_state['menu_option'][0] !=st.session_state['menu_option'][1]:
       st.session_state['menu_option'][0] =st.session_state['menu_option'][1]

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.