forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing on_change_callback for CustomComponents (streamlit#8633)
## Describe your changes In the past, some custom components have used a patch (https://gist.github.com/okld/1a2b2fd2cb9f85fc8c4e92e26c6597d5) to register an on_change callback. Recently, we have done some refactoring that broke this workaround. This PR is a suggestion to extend our official API to make the patch redundant. Note that we only want to pass the `on_change_callback` and not the `args` and `kwargs`. The `register_widget` function today uses `args` and `kwargs` as keywords to pass to the `on_change callback`. Besides the unfortunate naming - these are special keywords meant for functions themselves and not for pass-through arguments - we are thinking about deprecating them entirely, since you can wrap the callback easily to pass the arguments. ## GitHub Issue Link (if applicable) Closes streamlit#3977 Related to victoryhb/streamlit-option-menu#70 ## Testing Plan - Explanation of why no additional tests are needed - Unit Tests (JS and/or Python) - A new unit test is added to make sure the on_change callback is called when the value changes during a ScriptRun - E2E Tests - prepare `on_change` callback test in the `option_menu` function - Any manual testing needed? - I manually tested it on the example of [streamlit-option-menu](https://github.com/victoryhb/streamlit-option-menu) --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
- Loading branch information
1 parent
c4147ea
commit ad7f3d8
Showing
6 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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