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

Cannot set value of dropdown in on_change #4719

Open
1 task done
jeb192004 opened this issue Jan 15, 2025 · 0 comments
Open
1 task done

Cannot set value of dropdown in on_change #4719

jeb192004 opened this issue Jan 15, 2025 · 0 comments

Comments

@jeb192004
Copy link

Duplicate Check

Describe the bug

when attempting to set the value of a dropdown, the value after changed ends up empty.

if i print the value after setting it, it does print the value i changed it to.

If i do not attempt to set a value, it does use the text from the selected option as the value and correctly displays that.

Screenshot 2025-01-15 at 4 48 48 PM Screenshot 2025-01-15 at 4 49 02 PM

Code sample

Code
def drop_change(e):
        print(e.control.value)
        e.control.value="show this instead of the actual value"
        page.update()
        print("changed val", e.control.value)#this does print "show this instead of the actual value" but it does not appear in the dropdown after changed
        
update_frequency_dropdown = ft.Dropdown(
        width=300,
        options=[
            ft.dropdown.Option("Once a day(default)"),
            ft.dropdown.Option("Once a week"), 
            ft.dropdown.Option("Once a month")
            ],
        label="Update Frequency",
        on_change=lambda e: drop_change(e)
    )

To reproduce

run the code snippet i shared

Expected behavior

i expect the value set to replace the label in the dropdown after its selected. similar to how the selected option value would replace the label in the dropdown after selected(screenshot).
Screenshot 2025-01-15 at 4 58 16 PM

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

latest

Flet version

0.25.2

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

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