flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
10.86k stars 417 forks source link

Dropdown lists reset displayed value in web app on page reload #3761

Open mghiggins opened 1 month ago

mghiggins commented 1 month ago

Duplicate Check

Describe the bug

I've build a web app using flet that includes ft.Dropdown controls. I noticed that the app's web page force-reloads every so often (how do I stop that, btw?), and when it does, the values displayed in the dropdown lists reset to the first value in the list. How do I stop this from happening?

Code sample

Logs ```python [Paste your code here] ```

To reproduce

Build a web app with a single dropdown, build it for the web, change the value in the dropdown, and reload the web page.

Expected behavior

The selected value should be persisted across page reloads

Screenshots / Videos

Screenshots / Video demonstration [Upload media here]

Operating System

macOS

Operating system details

MacOS 15.0

Flet version

0.23

Regression

No, it isn't

Suggestions

I asked Google Gemini and it suggested inheriting a class from ft.UserControl, storing the dropdown value in page.session, and forcibly setting it on build(). That didn't work :( and also seems kind of clunky.

Logs

Logs ```console [Paste your logs here] ```

Additional details

No response

ndonkoHenri commented 1 month ago

Please can you share a capture with the issue?