streamlit / streamlit

Streamlit — A faster way to build and share data apps.

Home Page:https://streamlit.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow st.form enter_to_submit to work for non-text elements

nickgreengithub opened this issue · comments

Checklist

  • I have searched the existing issues for similar feature requests.
  • I added a descriptive title and summary to this issue.

Summary

I found that enter to submit only works for text entry elements - it doesn't work for:

  • radio selections
  • dataframe selections
  • number inputs
  • presumably others (selectbox etc.)

Why?

When I test my own forms, which rely on the st.dataframe row selection feature, intuitively I select and press Enter (Return) and expect the form to submit.

Limiting this only to text reduces the usefulness of forms, quite a lot for me

How?

however the text input works -- repeat for all input elements!

Squeezing in the 'Enter to submit' message probably isn't possible, but that's okay.

Additional Context

import streamlit as st
import pandas as pd

test_number = 0

with st.form(key='form_select_step',enter_to_submit=True):

a1,a2,a3,a4 = st.columns([25,25,25,25])

test_radio = a1.radio('radio',['test1','test2','test3'],index=0)

test_dataframe = pd.DataFrame({'test':[1,2,3]})
a2.write('dataframe')
test_dataframe_selection = a2.dataframe(test_dataframe,on_select='rerun',selection_mode='single-row')

test_number = a3.number_input('number',value=10)
test_string = a4.text_input('string',value='test')

st.form_submit_button('form submit')

a1,a2,a3,a4 = st.columns([25,25,25,25])

a1.write('Test Radio:')
a1.write(test_radio)

a2.write('Test Dataframe Selection:')
a2.write(test_dataframe_selection)

a3.write('Test Number:')
a3.write(test_number)

a4.write('Test String:')
a4.write(test_string)

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Visits

Hey, it does work for st.number_input. I can see the point of having it work for other elements as well but they are definitely a bit less obvious UX since you don't really have a cursor/input field there.