m-wrzr / streamlit-searchbox

Streamlit searchbox that dynamically updates and provides a list of suggestions based on a provided function
MIT License
253 stars 33 forks source link

Search box loses focus w/ Streamlit 1.35.0 #47

Open metalshanked opened 6 months ago

metalshanked commented 6 months ago

Hi, i updated Streamlit to 1.35.0 (from 1.34.0) and the search box loses focus after typing a few characters. Note: I see a page reload happens for a split second when the focus is lost and reset i do not get any errors and have not changed any config.

st_searchbox(
            callback_fn,
            key="my_input",
            label="",
            edit_after_submit='option',  # "disabled", "current", "option", "concat"
            placeholder="Search...",
            clear_on_submit=False,
            default='',
            rerun_on_update=True,
            style_overrides={
                "clear": {
                    "width": 20,
                    "height": 20,
                    # default: circle-filled
                    # other: cross
                    "icon": "circle-unfilled",
                    "stroke-width": 2,
                    "stroke": "red",
                },
            }
        )
m-wrzr commented 5 months ago

Hey, thanks for the bug report. I could replicate this with streamlit versions 1.35 and 1.36 by typing (very) fast until the searchbox looses focus (looks like the iframe is reloading).

I'll create a bug report on the streamlit repostiory. The issue seems to have started with this commit https://github.com/streamlit/streamlit/commit/d302553a3724e0142b2a4420649e228a0632d36e - I don't think this is sth. that can be fixed from the component side, so we'll probably have to wait until streamlit is updated.

Issue is here: https://github.com/streamlit/streamlit/issues/9002

m-wrzr commented 4 months ago

Problem seems to be worse with version 1.37, I've added an exception for it to the setup.py / install_requires

m-wrzr commented 3 months ago

I've added a min_execution_time parameter to delay the next rerun and avoid the reset issues atm. This is supposed to be removed, once the original issue is resolved.