Skip to content

Conversation

@tconkling
Copy link
Contributor

@tconkling tconkling commented Apr 6, 2021

If you forget to create a st.beta_submit_button inside your form, we warn you.

  • FormsManager tracks the number of submit buttons that each form has. (This will generally be either 1 or 0.)
  • When SubmitFormButton is mounted, it increments FormsManager's submitButtonCount for its form. The reverse happens on unmount.
  • <Form> creates a timer on creation. If its hasSubmitButton state is not true when the timer fires, it will show a warning.

(The timer duration, and the warning text, are both placeholder - we'll get a product review on this later. This PR is strictly for functionality.)

* st_form:
  Set baseUrl to .
  Speed up CircleCI more (streamlit#3025)
  Add events to keep track of theme changes and other theme stats (streamlit#3012)
  Have MetricsManager enqueue events when disconnected (streamlit#3011)
  Fix for query param issue with base url (streamlit#2894)
  Add fuzzy search to selectbox (streamlit#2933)
  Informative repr methods for our python classes (streamlit#3027)
  ComponentInstance: handle iframe changes (streamlit#3015)
# By Tim Conkling (7) and others
# Via GitHub (3) and Tim Conkling (1)
* st_form:
  FormsManager (streamlit#3046)
  Added "allow-downloads" to the sandbox attributes (streamlit#3053)
  Small fix for `make pylint` command (streamlit#3062)
  Set genericColors properly and make theme defs more consistent (streamlit#3051)
  Downgrade st.warning in local_sources_watcher to a log (streamlit#3050)
  Extend docstring of st.image (streamlit#3055)
  Move docs.streamlit.io to Segment (streamlit#3005)
  Fix bokeh example in docs (`legend` arg) (streamlit#2907)
  Remove incorrect markdown table styling (streamlit#3038)
  document getattr
  Show the beta_warning only a single time per object
  object_beta_warning: handle every __ magic method
  object_beta_warning: handle the subscript operator
  beta_util_test
  Move secrets out of beta
  [Security] Upgrade y18n to 4.0.1 or later (streamlit#3041)
  Fix gap not working on Safari (streamlit#3042)
  formatting
  call _repr_html_ when available

# Conflicts:
#	frontend/src/components/core/Block/Block.tsx
#	frontend/src/components/widgets/Form/Form.tsx
#	frontend/src/components/widgets/Form/FormSubmitButton.tsx
#	frontend/src/components/widgets/Form/FormsData.test.ts
#	frontend/src/components/widgets/Form/FormsManager.ts
@tconkling tconkling requested review from a team and kantuni April 6, 2021 03:02
"never be sent to your Streamlit app." +
"\n\nTo create a submit button, use the `st.beta_submit_button()` function."

export class Form extends PureComponent<Props, State> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we didn't use hooks here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a long thread in Slack, but basically: useEffect cleanup callbacks aren't being called in Enzyme tests when a component is unmounted. These classes originally used hooks, and I rewrote them so that I could have running tests.

(Also, Enzyme's shallow() function is incompatible with hooks.)

size={Size.SMALL}
disabled={props.disabled || props.hasInProgressUpload}
onClick={() => props.widgetMgr.submitForm(props.element)}
export class FormSubmitButton extends PureComponent<Props> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

* st_form:
  Fix image galleries (streamlit#3044)
  Is this a red herring also?
  See if pylint was red herring
  Update sphinx
  Specify pylint version
  Fix pylint errors
@tconkling tconkling merged commit e5a9103 into streamlit:st_form Apr 6, 2021
@tconkling tconkling deleted the tim/MissingSubmitButtonWarning branch April 6, 2021 17:00
tconkling added a commit that referenced this pull request Apr 6, 2021
* st_form:
  Form: warn when submit button is missing (#3079)
  Fix image galleries (#3044)
  Is this a red herring also?
  See if pylint was red herring
  Update sphinx
  Specify pylint version
  Fix pylint errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants