Description
Description
When open 1 dialog, close it and open another dialog, after closing the second dialog, a ghost dialog appeared.
Code example to reproduce the issue:
import flet as ft
import time
def main(page: ft.Page):
page.title = "AlertDialog examples"
dlg = ft.AlertDialog(
title=ft.Text("Hello, you!"), on_dismiss=lambda e: print("Dialog dismissed!")
)
def close_dlg(e):
dlg_modal.open = False
page.update()
def close_dlg_msgbox(e):
dlg_msgbox.open = False
page.update()
def show_msgbox(e):
close_dlg(e)
#time.sleep(.1)
page.dialog = dlg_msgbox
dlg_msgbox.open = True
page.update()
dlg_msgbox = ft.AlertDialog(
title=ft.Text("Info"),
modal=True,
content=ft.Text("Files deleted"),
actions=[
ft.TextButton("Close", on_click=close_dlg_msgbox),
],
actions_alignment=ft.MainAxisAlignment.END,
on_dismiss=lambda e: print("Modal dialog dismissed!"),
)
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=show_msgbox),
ft.TextButton("No", on_click=close_dlg),
],
actions_alignment=ft.MainAxisAlignment.END,
on_dismiss=lambda e: print("Modal dialog dismissed!"),
)
def open_dlg(e):
page.dialog = dlg
dlg.open = True
page.update()
def open_dlg_modal(e):
page.dialog = dlg_modal
dlg_modal.open = True
page.update()
page.add(
ft.ElevatedButton("Open dialog", on_click=open_dlg),
ft.ElevatedButton("Open modal dialog", on_click=open_dlg_modal),
)
ft.app(target=main)
Describe the results you received:
The source was copied from https://flet.dev/docs/controls/alertdialog/, add one more dialog (dlg_msgbox)
start -> "Open modal dialog" -> "Yes" -> "Close"
After clicking "Close", a ghost dialog appeared.
Depending on the modal of last dialog, the screen will be frozen by the ghost dialog if the last dialog's modal=True.
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
If I add a sleep (between close dialog and open dialog), it may sometime fix it, but not 100%.
Flet version (pip show flet
):
In fact, older version (e.g. 0.7.4) also have this bug
flet==0.8.4
flet-core==0.8.4
flet-runtime==0.8.4
(paste your output here)
Operating system:
Windows 11 Pro
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Additional environment details: