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

skip_route_change_event in page.go() does not work #2920

Open
michalswistowski opened this issue Mar 21, 2024 · 1 comment
Open

skip_route_change_event in page.go() does not work #2920

michalswistowski opened this issue Mar 21, 2024 · 1 comment
Labels
bug Something isn't working enhancement Improvement/Optimization has reproducible steps Issue is reproducible

Comments

@michalswistowski
Copy link

Description

while using page.go(skip_route_change_event=True) it should skip page.on_route_change. Instead, event is triggered no matter what, in this code example, while clicking on "Go home" button, it should not do anything, neither print("event route") nor append view.

Code example to reproduce the issue:

import flet as ft

def main(page: ft.Page):
    page.title = "Routes Example"

    def route_change(route: ft.RouteChangeEvent):
        print("event route")
        page.views.clear()
        page.views.append(
            ft.View(
                "/",
                [
                    ft.AppBar(title=ft.Text("Flet app"), bgcolor=ft.colors.SURFACE_VARIANT),
                    ft.ElevatedButton("Visit Store", on_click=lambda _: page.go("/store")),
                ],
            )
        )
        if page.route == "/store":
            page.views.append(
                ft.View(
                    "/store",
                    [
                        ft.AppBar(title=ft.Text("Store"), bgcolor=ft.colors.SURFACE_VARIANT),
                        ft.ElevatedButton("Go Home", on_click=lambda _: page.go("/", skip_route_change_event=True)),
                    ],
                )
            )
        page.update()

    def view_pop(view):
        page.views.pop()
        top_view = page.views[-1]
        page.go(top_view.route)

    page.on_route_change = route_change
    page.on_view_pop = view_pop
    page.go(page.route)


ft.app(target=main)

Flet version:

Version: 0.21.2

Operating system:
Linux Ubuntu

@ndonkoHenri ndonkoHenri added bug Something isn't working enhancement Improvement/Optimization has reproducible steps Issue is reproducible labels Mar 25, 2024
@phanstudio
Copy link

i encountered the same issue

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 has reproducible steps Issue is reproducible
Projects
None yet
Development

No branches or pull requests

3 participants