Skip to content

bug: InteractiveViewer does not block scroll event from bubbling up to parent #6755

Description

@eliferin14-svg

Duplicate Check

Describe the bug

When I have an InteractiveViewer inside a scrollable element, like a Column, if I use the mouse wheel to zoom in the viewer it also scrolls the column

In the script pasted I tried to implement a callback (only on the first image) to disable column scrolling when I hover the viewer, but it just means that the column scroll state is reset to the zero position, and it is not an acceptable solution. On the second image you can see that you both zoom in/out and scroll the column

I am running flet on a Windows PC

Code sample

Code
import flet as ft

URL = "https://picsum.photos/800/600"


@ft.component
def ImageComparison():
    is_hovered, set_is_hovered = ft.use_state(False)
    print(is_hovered)

    def handle_enter(e: ft.HoverEvent):
        set_is_hovered(True)

    def handle_exit(e: ft.HoverEvent):
        set_is_hovered(False)

    return ft.Column(
        expand=True,
        scroll=None if is_hovered else ft.ScrollMode.AUTO,
        spacing=30,
        controls=[
            ft.Row(
                controls=[
                    ft.Text(
                        "Interactive with scroll lock when hovering",
                        weight=ft.FontWeight.BOLD,
                        width=120,
                    ),
                    ft.Container(
                        clip_behavior=ft.ClipBehavior.HARD_EDGE,
                        content=ft.GestureDetector(
                            # on_hover=handle_hover,
                            on_enter=handle_enter,
                            on_exit=handle_exit,
                            content=ft.InteractiveViewer(
                                content=ft.Image(
                                    src=URL,
                                    fit=ft.BoxFit.CONTAIN,
                                ),
                            ),
                        ),
                    ),
                ],
                vertical_alignment=ft.CrossAxisAlignment.CENTER,
            ),
            ft.Row(
                controls=[
                    ft.Text("Interactive", weight=ft.FontWeight.BOLD, width=120),
                    ft.Container(
                        clip_behavior=ft.ClipBehavior.HARD_EDGE,
                        content=ft.InteractiveViewer(
                            content=ft.Image(
                                src=URL,
                                fit=ft.BoxFit.CONTAIN,
                            ),
                        ),
                    ),
                ],
                vertical_alignment=ft.CrossAxisAlignment.CENTER,
            ),
        ],
    )


def main(page: ft.Page):
    page.title = "Image Comparison"
    page.render(ImageComparison)


ft.run(main)

To reproduce

Run the script and try scrolling with mouse wheel

Expected behavior

I expect that when I scroll on the interactive viewer I only zoom in/out instead of scrolling the column aswell

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

11

Flet version

0.86.5

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions