-
Notifications
You must be signed in to change notification settings - Fork 576
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
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.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working