Skip to content

Commit

Permalink
fix pre-commit; remove 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
m-wrzr committed Oct 28, 2024
1 parent a44fef8 commit bb2bda6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10", "3.12"]
python-version: ["3.9", "3.11", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10", "3.12"]
python-version: ["3.9", "3.11", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -37,7 +37,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10", "3.12"]
python-version: ["3.9", "3.11", "3.13"]
# TODO: test with latest streamlit version
streamlit-version: ["1.25", "1.30", "1.31", "1.36"]

steps:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ reset_function: Callable[[], None] | None = None
Function that will be called when the combobox is reset.

```python
submit_function: Callable[[str], None] | None = None
submit_function: Callable[[Any], None] | None = None
```

Function that will be called when a new option is selected.
Function that will be called when a new option is selected, with the selected option as argument.

---

Expand Down Expand Up @@ -243,3 +243,4 @@ We welcome contributions from everyone. Here are a few ways you can help:
- [@Jumitti](https://github.com/Jumitti) `st.rerun` compatibility
- [@salmanrazzaq-94](https://github.com/salmanrazzaq-94) `st.fragment` support
- [@hoggatt](https://github.com/hoggatt) `reset_function`
- [@bram49](https://github.com/bram49) `submit_function`
15 changes: 10 additions & 5 deletions streamlit_searchbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def st_searchbox(
debounce: int = 150,
min_execution_time: int = MIN_EXECUTION_TIME_DEFAULT,
reset_function: Callable[[], None] | None = None,
submit_function: Callable[[str], None] | None = None,
submit_function: Callable[[Any], None] | None = None,
key: str = "searchbox",
rerun_scope: Literal["app", "fragment"] = "app",
**kwargs,
Expand Down Expand Up @@ -254,8 +254,9 @@ def st_searchbox(
within the component in some streamlit versions. Defaults to 0.
reset_function (Callable[[], None], optional):
Function that is called after the user reset the combobox. Defaults to None.
submit_function (Callable[[str], None], optional):
Function that is called after the user submits an option from the combobox. Defaults to None.
submit_function (Callable[[any], None], optional):
Function that is called after the user submits a new/unique option from the
combobox. Defaults to None.
key (str, optional):
Streamlit session key. Defaults to "searchbox".
Expand Down Expand Up @@ -313,9 +314,13 @@ def st_searchbox(
)

if interaction == "submit":
submit_value = st.session_state[key]["options_py"][value] if "options_py" in st.session_state[key] else value
submit_value = (
st.session_state[key]["options_py"][value]
if "options_py" in st.session_state[key]
else value
)

# Ensure submit_function only runs when value changed. Not on each fragment/app rerun
# ensure submit_function only runs when value changed
if st.session_state[key]["result"] != submit_value:
st.session_state[key]["result"] = submit_value
if submit_function is not None:
Expand Down

0 comments on commit bb2bda6

Please sign in to comment.