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

Make ControlEvent.data of type Optional[str] with None as default #4800

Merged
merged 3 commits into from
Feb 10, 2025

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Jan 30, 2025

Resolves #4786

Test Code

import flet as ft


def main(page: ft.Page):
    page.add(
        ft.TextField(
            label="Hello",
            on_click=lambda e: print(f"Clicked: {e.data!r}"),  # None
            on_focus=lambda e: print(f"Focused: {e.data!r}"),  # None
            on_change=lambda e: print(f"Changed: {e.data!r}"),  # String
        ),
    )


ft.app(target=main)

Additional details

Complementary PRs:

Summary by Sourcery

Make ControlEvent.data optional.

Bug Fixes:

  • Fix issue where ControlEvent.data was always a string, even when no data was provided.

Enhancements:

  • Improve type handling in ControlEvent by making data field optional.

@FeodorFitsner FeodorFitsner merged commit 9e0d9fc into main Feb 10, 2025
3 checks passed
@FeodorFitsner FeodorFitsner deleted the ndonkoHenri/event-data-type-none branch February 10, 2025 05:23
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

Successfully merging this pull request may close these issues.

ControlEvent.data should be of type Optional[str] and default to None
2 participants