Repository navigation
feat(FileUploader): empty the uploader after a successful submit - #15
Merged
Merged
Conversation
…int/front#24) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… and anything drawn on submit stay (#front24) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes i2mint/front#24 (needs the
clear_after_submitfield from i2mint/front#35, merged; the code reads it with a default of True so it also runs on an older front).After a successful, non-
auto_submitsubmit, everyFileUploaderof the section (also inside aMultiSourceInput) withclear_after_submit(default True) is emptied, so the next batch doesn't start from the previous selection. Streamlit can only empty an uploader by giving it a new key, so the uploader keeps anst.empty()slot, bumps a key generation in session state and draws a fresh uploader into the same slot in the same run: no rerun, so the output and anything the function oron_submitdraws stay in place.clear_after_submit=Falsekeeps the old behaviour. The widget now has an explicit key (this also fixes a crash with two identical unkeyed uploaders on a page).Tests:
tests/test_file_uploader_clear.pyruns the app headlessly withAppTest(clears, output kept, second batch clean, opt-out, failed submit keeps the selection, multi-source).Adversarial review (fresh Opus subagent, two rounds): round 1 found my first design (rerun + stashed output) lost anything drawn by the function/
on_submit, and keyed the stash by section name: replaced by the in-place redraw. Round 2 found a stale slot could be redrawn for a source not drawn in this run (apps cached across runs): slots are now reset at the start of each run. Deferred: uploaders inside aKwargsInputare not cleared (#14).Dependents gate (
priv test-dependents streamlitfront --transitive): pass.🤖 Generated with Claude Code