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

alert dialog doesn't close #2011

Closed
1 task done
NaotoTakata opened this issue Nov 1, 2023 Discussed in #1980 · 3 comments
Closed
1 task done

alert dialog doesn't close #2011

NaotoTakata opened this issue Nov 1, 2023 Discussed in #1980 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@NaotoTakata
Copy link

NaotoTakata commented Nov 1, 2023

Discussed in #1980

Originally posted by NaotoTakata October 23, 2023

When I run the application and click the "No" button in the modal, the modal closes as It should be , but when I visit the store page and then return to the index page , clicking the "No" button in the modal doesn't close the modal.

Code sample

import flet as ft


def main(page: ft.Page):
    def close_dlg(e):
        dlg_modal.open = False
        page.update()

    dlg_modal = ft.AlertDialog(
        modal=True,
        title=ft.Text("Please confirm"),
        content=ft.Text("Do you really want to delete all those files?"),
        actions=[
            ft.TextButton("Yes", on_click=close_dlg),
            ft.TextButton("No", on_click=close_dlg),
        ],
        actions_alignment=ft.MainAxisAlignment.END,
        on_dismiss=lambda e: print("Modal dialog dismissed!"),
    )

    def open_dlg_modal(e):
        page.dialog = dlg_modal
        dlg_modal.open = True
        page.update()

    def route_change(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")
                    ),
                    ft.ElevatedButton("Open dialog", on_click=open_dlg_modal),
                ],
            )
        )
        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("/")),
                    ],
                )
            )
        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, view=ft.AppView.WEB_BROWSER)

flet ver : 0.10.3
python ver : 3.9.10

Error message

No response

------------------------------------------------------

  • I have searched for answers to my question both in the issues and in previous discussions.
@NaotoTakata
Copy link
Author

Updating flet version from 0.10.3 to 0.12.0 solves the problem but , there's new bug that If you change the view several times , the application blacks out.

Animation

OS : Windows 10 Pro
flet : 0.12.0
python : 3.9.10

@FeodorFitsner
Copy link
Contributor

Related to #2082. Fix is coming.

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Nov 13, 2023
@FeodorFitsner FeodorFitsner added this to the Flet v0.12.1 milestone Nov 14, 2023
@NaotoTakata
Copy link
Author

Thank you for fixing.

flet is absolutelly greate which enables me to make a cool application easily.
I'm really excited for the upcoming update which is listed on roadmap page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants