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

Fix: Container.on_tap_down not called when on_click is not provided #3442

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

ndonkoHenri
Copy link
Collaborator

@ndonkoHenri ndonkoHenri commented Jun 10, 2024

#3064 (comment)

Test Code

import flet as ft

def main(page: ft.Page):
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    t = ft.Text()

    def container_click(e: ft.ContainerTapEvent):
        t.value = f"local_x: {e.local_x}\nlocal_y: {e.local_y}\nglobal_x: {e.global_x}\nglobal_y: {e.global_y}"
        t.update()

    page.add(
        ft.Column(
            [
                ft.Container(
                    content=ft.Text("Clickable inside container"),
                    alignment=ft.alignment.center,
                    bgcolor=ft.colors.GREEN_200,
                    width=200,
                    height=200,
                    border_radius=10,
                    on_tap_down=container_click,
                ),
                t,
            ],
            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
        ),
    )

ft.app(target=main)

Summary by Sourcery

This pull request addresses a bug where the Container.on_tap_down event was not triggered if the on_click event was not set. The fix ensures that on_tap_down is considered in the conditional checks, allowing the event to be properly handled.

  • Bug Fixes:
    • Fixed an issue where Container.on_tap_down was not called when on_click was not provided.

Copy link
Contributor

sourcery-ai bot commented Jun 10, 2024

Reviewer's Guide by Sourcery

This pull request addresses an issue where the Container.on_tap_down event was not being called when the on_click event was not provided. The changes ensure that the on_tap_down event is considered in the conditional checks for enabling the widget's interaction.

File-Level Changes

Files Changes
packages/flet/lib/src/controls/container.dart Updated the conditional logic to include onTapDown for enabling widget interaction and modified the onTap callback accordingly.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ndonkoHenri - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

packages/flet/lib/src/controls/container.dart Show resolved Hide resolved
@FeodorFitsner FeodorFitsner merged commit ef93025 into main Jun 10, 2024
3 checks passed
@FeodorFitsner FeodorFitsner deleted the fix-container-tap-down branch June 10, 2024 17:47
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.

2 participants