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

ControlEvent.data should be of type Optional[str] and default to None #4786

Open
ndonkoHenri opened this issue Jan 27, 2025 · 0 comments · May be fixed by #4800
Open

ControlEvent.data should be of type Optional[str] and default to None #4786

ndonkoHenri opened this issue Jan 27, 2025 · 0 comments · May be fixed by #4800
Assignees
Labels
enhancement Improvement/Optimization

Comments

@ndonkoHenri
Copy link
Contributor

At the moment ControlEvent.data (or precisely Event.data) is of type string and defaults to an empty string. This is misleading as one could think that's an actual data which was passed, whereas, seeing None will be a good indication that nothing was passed.

class ControlEvent(Event):
def __init__(self, target: str, name: str, data: str, control, page):
Event.__init__(self, target=target, name=name, data=data)

Test Code

import flet as ft


def main(page: ft.Page):
    page.add(
        ft.ElevatedButton("Hello", on_click=lambda e: print(f"Button clicked: {e.data!r}")), # same with on_focus, on_blur etc
    )


ft.app(main)
@ndonkoHenri ndonkoHenri added the enhancement Improvement/Optimization label Jan 27, 2025
@ndonkoHenri ndonkoHenri self-assigned this Jan 27, 2025
@ndonkoHenri ndonkoHenri moved this from 🆕 New to 👀 In review in Flet Development Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement/Optimization
Projects
Status: 👀 In review
Development

Successfully merging a pull request may close this issue.

1 participant