How to disable default text_input "Enter" action

Would like to disable the default “Enter” action of text_input.

1 Like

Hi @Arjun_Prasaath

There’s the disabled parameter for the st.text_input() method.

An example of how I used this for an app is provided in the following code snippet:

query_text = st.text_input('Enter your query:', placeholder = 'Enter query here ...', disabled=not uploaded_file)

which is used in the GitHub repo:

Hope this helps!

Best regards,
Chanin

Hi everybody!
Thank you @dataprofessor for your answer.
Maybe I simply don’t understand your code correctly, but I don’t think your suggestion tackles the problem. I think @Arjun_Prasaath wants to deactivate the function of a text_input to submit the entire form when pressing enter after filling it out.
I am facing the same challenge. My app involves multiple text_input widgets, and I don’t want user to submit unintentionally too early by pressing enter to confirm their input.
In that sense, I don’t want to disable the widget, but just the function of submitting the whole form on one enter-click.

2 Likes

I’m also facing a similar issue. The default action upon pushing enter for a text_input widget in a form is to submit the form. This is not a desirable default if there are multiple text_input widgets. Making the hotkey, ⌘ + enter, to submit the form like it is for text_area would be a better solution.

No new information, but I would like to report the same issue. I have a longish form (a demographic survey to be filled out before participating in my experiment), and I don’t want the user to “lose their work” if they mistakenly press enter while they’re filling out the form.

Hi @zabillet , @sa28 , @zyankarli, and @Arjun_Prasaath , I totally understand why you would want this disabled as there are a multitude of reasons.

If you could, could you upvote this post as our product team uses github issue interactions to help prioritize work:

Hi @willhuang,
thanks so much for organizing the debate and providing the link here. Upvoted now.
Cheers!

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