Prevent st.text_input from executing at blur event

I have trying to build a chatbot using streamlit. I have used standard text_input component to accept user input. Though it says hit Enter but it also activates when focus goes to something else (blur event) like clicking anywhere on page or changing tabs to copy stuff that leads to incorrect input to be submitted.

Is there anyway to prevent this default behavior and only allow it to accept when user hits enter?

I recommend using the new st.chat_input in place of st.text_input, especially for the chatbot use cases.
Here’s a link to the docs for the new feature.

1 Like

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