Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Feb 9, 2021

Fixes #2701.

Our saved widget state on the backend basically comes straight from the frontend. The user types something, the frontend sends over the new widget state, and the backend reruns using the new state. This normally works great.

The problem is that the backend relies on the frontend to get its widget state. So when you remove a widget from your script and save, triggering a rerun, and the frontend never gets consulted on any of this, the backend still remembers the old state, causing the bug above.

I added a line post-rerun to clear widgets that no longer exist from the widget state.

@ghost ghost self-requested a review February 9, 2021 01:37
Copy link
Collaborator

@vdonato vdonato left a comment

Choose a reason for hiding this comment

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

Would it be possible to write a test for this by somehow modifying ctx.widget_ids_this_run.items() in a script run to remove some widgetId so that the run doesn't output the corresponding delta?

It'd be valuable to give it a shot, but I also have a hunch that this might be a hard test to write

@ghost
Copy link
Author

ghost commented Feb 16, 2021

@vdonato Ok, I added a test.

The script runner takes as input a set of widget states saved from the last run. So I'm just running a random script, passing in widget states with a nonexistent widget ID, and afterward asserting that the widget ID is no longer saved.

@vdonato
Copy link
Collaborator

vdonato commented Feb 17, 2021

@vdonato Ok, I added a test.

The script runner takes as input a set of widget states saved from the last run. So I'm just running a random script, passing in widget states with a nonexistent widget ID, and afterward asserting that the widget ID is no longer saved.

Woo nice! That required jumping through fewer hoops than I would have expected.

@ghost ghost merged commit eb87139 into streamlit:develop Feb 17, 2021
@ghost ghost deleted the fix-text-input-clearing branch February 17, 2021 19:05
CFrez pushed a commit to CFrez/streamlit that referenced this pull request Feb 18, 2021
* remove nonexistent elements from widget states

* fix typo

* add test
schaumb pushed a commit to FloWide/streamlit that referenced this pull request Feb 22, 2021
* remove nonexistent elements from widget states

* fix typo

* add test
tconkling added a commit to tconkling/streamlit that referenced this pull request Feb 22, 2021
* develop:
  Color picker - show value (streamlit#2817)
  Minor improvements to local E2E testing  (streamlit#2807)
  Fix datetime timezone handling in data frames (streamlit#2784)
  Remove nonexistent elements from widget state (streamlit#2760)
  Shared selectbox (streamlit#2795)
kmcgrady pushed a commit that referenced this pull request Feb 24, 2021
* created conditional rendering of controls & tests

* reorganized and added tests

* removed accidently added unneeded import

* alter flex, padding and gap to align columns

* adjusted spacing since not duplicated

* alter flex, padding and gap to align columns

* adjusted spacing since not duplicated

* Fix checkbox spacing (#2738)

* remove extra padding

* remove snapshot completely

* add snapshot back in

* remove snapshots

* remove rest of snapshots

* add snapshots back in

* Autofocus "clear cache" button (#2739)

* autofocus clear cache button

* add test

* update test

* fix lint

* `allow_multiple_files` -> `accept_multiple_files` (#2761)

* Update component-template submodule to latest (#2767)

Point our `component-template` submodule to the latest commit in that repo.

(Among other things, this will de-dupe a bunch of the `component-lib` code that used to live in `component-template` before being pulled into its own npm package.)

* Slider thumb values are always visible (#2724)

* Close #2699

* Override Thumb subcomponent completely

* Fixed linting errors

Co-authored-by: Ken McGrady <[email protected]>

* Create base color picker for use with API and internally (#2778)

* Copy to shared and cleanup

* Cleanup

* remove comment

* config: client.showTracebacks (#2770)

Adds a new config option, `"client.showTracebacks"`. By default, it's `True`.

If the option is set to `False`, then uncaught exceptions in a Streamlit app will result in a generic "Something went wrong!" warning in the browser, rather than the exception and its traceback

This logic happens in the `error_util.handle_uncaught_app_exception` function, rather than directly within ScriptRunner.

`scriptrunner_test`, `caching_test`, and `streamlit_test` have new tests that verify the right thing happens when exceptions are thrown in different circumstances with this config option turned on and off.

Closes #1032

* Shared selectbox (#2795)

* Remove nonexistent elements from widget state (#2760)

* remove nonexistent elements from widget states

* fix typo

* add test

* Fix datetime timezone handling in data frames (#2784)

* save changes

* remove redundant change

* fix tests

* fix quotes

* add tests and other fixes

* fix lint

* update protobufs and tests

* add e2e test

* fix quotes

* update test

* Revert "removed accidently added unneeded import"

This reverts commit f886adc.

* Revert "reorganized and added tests"

This reverts commit d3632d9.

* Revert "created conditional rendering of controls & tests"

This reverts commit 7c4400e.

* updated tests

* fixed lint

* correct percentages in spec for test

* update st_image column image

* added comment to HoizontalBlock

* added Issue/PR to comment

Co-authored-by: bh-streamlit <[email protected]>
Co-authored-by: Simon Biggs <[email protected]>
Co-authored-by: Tim Conkling <[email protected]>
Co-authored-by: Henrikh Kantuni <[email protected]>
Co-authored-by: Ken McGrady <[email protected]>
Co-authored-by: karrie <[email protected]>
tconkling added a commit to tconkling/streamlit that referenced this pull request Feb 24, 2021
* develop:
  Update "showErrorDetails" config description and docs (streamlit#2841)
  Pause Dependabot updates for non-security-related issues (streamlit#2840)
  client.showTracebacks -> showErrorDetails (per product) (streamlit#2837)
  Color picker - show value (streamlit#2817)
  Minor improvements to local E2E testing  (streamlit#2807)
  Fix datetime timezone handling in data frames (streamlit#2784)
  Remove nonexistent elements from widget state (streamlit#2760)
  Shared selectbox (streamlit#2795)
This pull request was closed.
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.

Text input widget sometimes clears for no reason [regression]

1 participant