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

Unable to Retrieve 'data' Property from PopupMenuItem in Version 0.21.1 #2826

Closed
Klu1d opened this issue Mar 7, 2024 · 4 comments · Fixed by #2882
Closed

Unable to Retrieve 'data' Property from PopupMenuItem in Version 0.21.1 #2826

Klu1d opened this issue Mar 7, 2024 · 4 comments · Fixed by #2882
Assignees
Labels
bug Something isn't working enhancement Improvement/Optimization

Comments

@Klu1d
Copy link

Klu1d commented Mar 7, 2024

Issue:
When I updated flet to version 0.21.1, I encountered the issue that it became impossible to retrieve the 'data' property when clicking on PopupMenuItem. Prior to this, in version 0.20.0, I could retrieve this property from PopupMenuItem.

Demonstrations:
flet_version_0.20.0.webm
flet_version_0.21.1.webm

Code:

import flet as ft

def main(page: ft.Page):
    def lola(e):
        print('Current flet Version 0.21.1: ', e.control.data)
    options = ft.PopupMenuButton(
            icon=ft.icons.MORE_HORIZ_OUTLINED,
            visible=True,
            items=[
                ft.PopupMenuItem(text="change", data='tata'),
                ft.PopupMenuItem(text="delete", data='tata', on_click=lola),
            ]
        )
    
    page.add(options)

ft.app(target=main)
@Klu1d Klu1d closed this as completed Mar 7, 2024
@FeodorFitsner
Copy link
Contributor

Sorry, what was the issue?

@Klu1d
Copy link
Author

Klu1d commented Mar 7, 2024

I apologize for not providing a response earlier. I'm not entirely sure what the issue was, but I made some changes to the project architecture and reinstalled the latest version of Flet. I've come to the conclusion that the problem wasn't with Flet itself, but rather with how I wrote the code.

Despite checking the code with different versions and isolating the provided code from my project, the problem was still resolved by reinstalling: pip install -U flet.

@Klu1d
Copy link
Author

Klu1d commented Mar 9, 2024

Sorry, what was the issue?

It seems I rushed again. Please, check the code I provided for versions 0.20 and 0.21.1.

@Klu1d Klu1d reopened this Mar 9, 2024
@ndonkoHenri ndonkoHenri added bug Something isn't working enhancement Improvement/Optimization labels Mar 9, 2024
@ndonkoHenri ndonkoHenri self-assigned this Mar 9, 2024
@ndonkoHenri ndonkoHenri moved this from 🆕 New to 🏗 In progress in Flet Development Mar 9, 2024
ndonkoHenri added a commit that referenced this issue Mar 9, 2024
@ndonkoHenri ndonkoHenri linked a pull request Mar 15, 2024 that will close this issue
@ndonkoHenri ndonkoHenri moved this from 🏗 In progress to 👀 In review in Flet Development Mar 20, 2024
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Flet Development Apr 1, 2024
@ndonkoHenri
Copy link
Contributor

A pre-release with the fix concerning this issue is now available. Try it and report if you face any further issues or have any questions:

pip install flet --pre

zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* initial commit

* Pass data to Control.__init__
Fixes flet-dev#2826

* CircleAvatar: on_image_error

* Card: clip_behavior, is_semantic_container, show_border_on_foreground

* Checkbox: semantics_label, shape, splash_radius, border_side, is_error

* DragTarget: on_move, deprecated DragTargetAcceptEvent in favour of DragTargetEvent

* Draggable: on_drag_start, on_drag_end

* More types

* Divider: indent, end_indent

* Fix flet-dev#2839

* Stack: alignment, fit

* Divider: rename indent to leading_indent and end_indent to trailing_indent

* Draggable: rename on_drag_end to on_drag_complete

* Checkbox: rename border_side to border

* Revert "Checkbox: rename border_side to border"

This reverts commit b92ce30.

* Card: variant

* VerticalDivider: leading_indent, trailing_indent

* Tooltip: exclude_from_semantics, enable_tap_to_dismiss

* Reformat _set_attr calls

* TimePicker: orientation

* FAB - dart: colors, elevation, enableFeedback

* ProgressRing: stroke_cap, stroke_align, semantics_label, semantics_value

* ProgressBar: border_radius, semantics_label, semantics_value

* OutlinedButton: clip_behavior

* NavBar: animation_duration

* AlertDialog: action_button_padding, clip_behavior, icon_padding, shadow_color, surface_tint_color

* ListTile: enable_feedback, horizontal_spacing, min_leading_width, min_vertical_padding, selected_color, selected_tile_color, splash_color, style

* Image: exclude_from_semantics, filter_quality, semantics_label

* SelectionArea: on_change

* ListView: semantic_child_count, clipBehavior

* FAB: colors, elevations, enable_feedback, clip_behavior

* ElevatedButton: clip_behavior,

* SnackBar: clip_behavior, shape, on_visible

* Slider: interaction, overlay_color

* IconButton: alignment, disabled_color, enable_feedback, hover_color, padding

* Radio: focus_color, hover_color, overlay_color, splash_radius, toggleable, visual_density

* GridView: semantic_child_count, clipBehavior

* Tabs: divider_height, enable_feedback, indicator_thickness

* Cleanup + Code Reformat

* Fix CI: import enum

* Reformat: replace is_dataclass with isinstance

* add kwargs in run_task

* Tabs: secondary

* Fix CI: typing error

* Option: alignment, on_click

* Dropdown: hint_content, icon_content, elevation, item_height, max_menu_height, icon_size, enable_feedback, padding, icon_enabled_color, icon_disabled_color, on_click

* Cleanup

* PopupMenuButton: clip_behavior, splash_radius, elevation, enable_feedback, icon_size, surface_tint_color, shadow_color, bgcolor, icon_color, shape, padding

* Dropdown: remove dense getter and setter

* PopupMenuItem: padding, height

* Page: locale_configuration

* Card: rename NORMAL to ELEVATED

* CircleAvatar: rename foreground_image_url and background_image_url to *_src

* UrlTarget enum

* PopupMenuButton: reintroduce on_cancelled, but as deprecated

* Reformat: created control.attrColor to ease color parsing

* ListView+GridView: cache_extent

* AppBar: elevation_on_scroll, shadow_color, surface_tint_color, clip_behavior, force_material_transparency, is_secondary, title_spacing, exclude_header_semantics

* Reformat: avoid spamming warnings

* TextField: fill_color, hover_color

* Dropdown: fill_color

* Fix failing CI: omitted parenthesis

* Locale: script_code

* Locale: rename used_locale to default_locale

* CupertinoBottomSheet default values

* CupertinoBottomSheet: check the type of content control

* Locale: rename default_locale to current_locale :)

* TimePicker.value: avoid splitting None

* AlertDialog: alignment, icon_color, scrollable, content_text_style,  title_text_style, actions_overflow_button_spacing,

* AppBar: toolbar_opacity, title_text_style, toolbar_text_style,shape

* parseMouseCursor: defaultMouseCursor

* Checkbox: visual_density, mouse_cursor

* Banner: content_text_style, margin, elevation, divider_color, shadow_color, surface_tint_color, on_visible

* CupertinoListTile: leading_size, leading_to_title

* Chip: surface_tint_color, color, click_elevation, clip_behavior, visual_density, border_side

* CupertinoRadio: toggleable, focus_color

* CupertinoSegmentedButton: click_color

* CupertinoSwitch: on_label_color, off_label_color

* Switch: hover_color, splash_radius, overlay_color, track_outline_color,mouse_cursor

* Snackbar: action_overflow_threshold

* Tabs: is_secondary, mouseCursor, clipBehavior

* Slider: mouse_cursor, secondary_track_value, secondary_active_color

* PopupMenuItem: mouse_cursor

* NavigationDrawerDestination: bgcolor

* NavigationDestination: bgcolor

* NavigationBar: overlay_color

* CupertinoTimerPicker: item_extent

* ExpansionTile: dense, enable_feedback, visual_density

* SearchBar: keyboard_type, view_surface_tint_color, autofocus

* NavigationRail: (un)selected_label_text_style | Destination: indicator_color, indicator_shape

* IconButton: mouse_cursor, visual_density

* Radio: mouse_cursor

* FAB: mouse_cursor

* DataTable: clip_behavior

* DatePicker: on_entry_mode_change

* ListTile: title_alignment, icon_color, text_color, shape, visual_density, mouse_cursor, title_text_style, subtitle_text_style, leading_and_trailing_text_style

* TimePicker: on_entry_mode_change

* Cleanup

* Fix failing CI concerning circular import

* Cleanup

* Remove None from enums

* Updated rive package version

* Added Rive to CI

---------

Co-authored-by: Feodor Fitsner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Improvement/Optimization
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants