solivc
November 29, 2023, 4:47pm
1
Running Locally
Python 3.11
streamlit==1.28.2
I have a text input box where the user will enter … some text.
I am using st.form and st.text_area
# Using the "with" syntax
with st.form(key='my_form'):
theme = st.text_area(label='Enter some text')
submit_button = st.form_submit_button(label='Submit')
However, as you can see, the user is given two instructions. Press Ctrl + enter to Submit. Or Press the Submit button to submit.
I want the submit button to be the only method available. Having two sets of instructions may confuse people. (Never underestimate non technical people).
Is there a way to just have the Submit button as the only way to Submit?
Hi @solivc ,
appreciate you making this post. We currently have a github issue where other users feel the same way:
opened 06:38AM - 11 Oct 23 UTC
type:enhancement
area:widgets
feature:st.form
### Checklist
- [X] I have searched the [existing issues](https://github.com/… streamlit/streamlit/issues) for similar feature requests.
- [X] I added a descriptive title and summary to this issue.
### Summary
Issues are related to st.text_input
- **Issue 1: "Press Enter to Submit" Confusion**
- Description: When users change widgets within forms, a "Press Enter to Submit" message is displayed. This message can be misleading, as the code under the "Submit Form" button doesn't execute unless the user explicitly triggers it.
- Request: Improve this behavior to enhance the user experience.
- **Issue 2: Automatic Widget Clearing Option**
- Description: There's a need for an option to automatically clear widgets after user input. Currently, a workaround is used to address this issue.
- Request: Implement a native feature to enhance the user experience.
- **Issue 3: Widget Input Delay**
- Description: There's a noticeable delay of 1-2 seconds after clicking a widget before users can start typing input. This delay is time-consuming and not user-friendly.
- Request: Address and improve this delay, or suggest alternative workarounds if available.
Please consider these issues for enhancement. We kindly request the Streamlit development team's attention and assistance to improve the user experience.
opened 08:47PM - 22 Oct 23 UTC
type:enhancement
feature:st.text_input
### Checklist
- [X] I have searched the [existing issues](https://github.com/st… reamlit/streamlit/issues) for similar feature requests.
- [X] I added a descriptive title and summary to this issue.
### Summary
Make the submit rules for text_input the same as the submit rules for chat_input in that it does not submit if Shift is pressed along with Enter.
Current rules for text_input: "if (e.key === "Enter") {"
Current rules for chat_input: "isEnterKeyPressed(e) && !shiftKey && !ctrlKey && !metaKey"
### Why?
chat_input is awesome but currently has many restrictions: "Chat input can only be used once per app page and inside the main area of the app. It cannot be used in the sidebar, columns, expanders, forms or tabs. We plan to support this in the future".
As a consequence I use a text_input for single chat inputs, and a text_area for multiline chat inputs, based on a button users have to press. I'd like for users to be able to seamlessly switch from a text_input to text_area element when they hit "Shift+Enter", since this seems to be the standard "add a new line" hotkey. The current submit rules for text_input make it impossible to add an eventhandler to perform the switch on that key combo however. I have to instead rely on a hotkey that does not include "Enter", which is likely less intuitive.
I am filing this feature request in the off chance that this feature request really is but a one-line change that does not break any existing workflows.
### How?
Perhaps this line: https://github.com/streamlit/streamlit/blob/f73d7556fa85b56ad6e41696398a47b592f80dbe/frontend/lib/src/components/widgets/TextInput/TextInput.tsx#L176C5-L176C29
Can go from
if (e.key === "Enter") {
to
if (e.key === "Enter" && !e.shiftKey ) {
### Additional Context
_No response_
Please upvote these issues as we currently use them to prioritize issues.
3 Likes
system
Closed
May 27, 2024, 7:06pm
3
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.