Bind widgets to query params - Part 4#13722
Bind widgets to query params - Part 4#13722mayagbarnes wants to merge 7 commits intoquery-param-bind-3from
Conversation
✅ PR preview is ready!
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📈 Significant bundle size change detected
Please verify that this change is expected. |
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0700%
🎉 Great job on improving test coverage! |
There was a problem hiding this comment.
Pull request overview
This PR adds the bind parameter to st.text_input, st.text_area, and st.number_input widgets, enabling two-way synchronization between widget values and URL query parameters. This is Part 4 of the "Bind widgets to query params" feature series.
Changes:
- Adds
bind="query-params"parameter support to three text/number input widgets - Implements URL seeding (widgets initialize from URL on page load)
- Implements URL sync (user input updates URL in real-time)
- Handles constraint enforcement (max_chars truncation, min/max clamping for numbers)
- Includes comprehensive error handling for invalid bind values
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
proto/streamlit/proto/TextInput.proto |
Adds optional query_param_key field to TextInput proto message |
proto/streamlit/proto/TextArea.proto |
Adds optional query_param_key field to TextArea proto message |
proto/streamlit/proto/NumberInput.proto |
Adds optional query_param_key field to NumberInput proto message |
lib/streamlit/elements/widgets/text_widgets.py |
Implements bind parameter for text_input and text_area, adds max_chars handling in Serde classes |
lib/streamlit/elements/widgets/number_input.py |
Implements bind parameter for number_input, adds min/max clamping in NumberInputSerde |
lib/tests/streamlit/elements/text_input_test.py |
Adds comprehensive unit tests for text_input bind functionality |
lib/tests/streamlit/elements/text_area_test.py |
Adds comprehensive unit tests for text_area bind functionality |
lib/tests/streamlit/elements/number_input_test.py |
Adds comprehensive unit tests for number_input bind functionality including clamping tests |
frontend/lib/src/components/widgets/TextInput/TextInput.tsx |
Registers query param binding when queryParamKey is set |
frontend/lib/src/components/widgets/TextInput/TextInput.test.tsx |
Adds frontend unit tests for query param binding |
frontend/lib/src/components/widgets/TextArea/TextArea.tsx |
Registers query param binding and refactors getStateFromWidgetMgr for consistency |
frontend/lib/src/components/widgets/TextArea/TextArea.test.tsx |
Adds frontend unit tests for query param binding |
frontend/lib/src/components/widgets/NumberInput/NumberInput.tsx |
Registers query param binding when queryParamKey is set |
frontend/lib/src/components/widgets/NumberInput/NumberInput.test.tsx |
Adds frontend unit tests for query param binding |
e2e_playwright/st_text_input.py |
Adds test app code for query param bound text inputs |
e2e_playwright/st_text_input_test.py |
Adds E2E tests for URL seeding, updates, and edge cases |
e2e_playwright/st_text_area.py |
Adds test app code for query param bound text areas |
e2e_playwright/st_text_area_test.py |
Adds E2E tests for URL seeding, updates, and edge cases |
e2e_playwright/st_number_input.py |
Adds test app code for query param bound number inputs |
e2e_playwright/st_number_input_test.py |
Adds E2E tests for URL seeding, clamping, and edge cases |
| if self.data_type == NumberInputProto.INT: | ||
| val = int(val) | ||
| # Clamp to min/max range (e.g., for values seeded from URL) | ||
| val = max(self.min_value, min(self.max_value, val)) |
There was a problem hiding this comment.
question: This seems like it's going to have broader effects than just for values seeded from URL. Is this desired behavior even if this value was set not from the URL query string?

Describe your changes
Bind Widgets to Query Params - Part 4
This PR adds the
bindparameter tost.text_input,st.text_area, andst.number_inputto enable two-way sync between widget values and URL query parameters.max_charstruncates seeded values;min/maxclamps number inputsStreamlitInvalidBindValueErrorfor invalid bind valuesTesting Plan