Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input fields losing their current in-progress value on re-render #779

Open
suhren opened this issue Sep 10, 2024 · 0 comments
Open

Input fields losing their current in-progress value on re-render #779

suhren opened this issue Sep 10, 2024 · 0 comments

Comments

@suhren
Copy link
Contributor

suhren commented Sep 10, 2024

I have a Solara application where there is a separate thread (solara.use_thread or solara.lab.use_task) that periodically performs some work and updates a text component, at some interval. In addition, there are some other components that use solara.InputInt/solara.InputFloat/solara.InputText that the user can interact with.

However, if the user is in the middle of inputting a value (the cursor is located in the Input component) and the thread runs its work and updates its text component, the current value of the Input component is resetted. This makes it very hard to input values if the thread runs at, .e.g. once every second, as it will just reset the value the user tries to input.

I know that there is a parameter called "continuous_update=True" that will set the value of the Input component for every single character inputted, but the problem is that this, in turn, would trigger a huge amount of updates in other places of my application, which I would want to avoid (e.g. a text field might contain 50 characters, which would mean 50 updates).

I checked with @maartenbreddels in the Solara discord server, and he suggested that this is a bug, and that i can open an issue here. He even created a small working example of the problem in PyCafe here (thanks!): https://py.cafe/maartenbreddels/solara-rerender-input-bug

If you try to input an integer into the first IntInput, your progress will be lost every second, so you need to be very quick when inputting the value. There are also some debug prints to show when a component is updated, and it actually seems like the input components are not updated when the thread is running, but even still the progress seems to be lost? I don't understand that.

This problem (so far) only occurs with solara iunput components, and other types of components behave as expected.

Python: 3.11.7
Solara: 1.39.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant