Skip to content

bug: AlertDialog randomly not showing when opened from another AlertDialog that closed itself beforehand #5684

@Creeper19472

Description

@Creeper19472

Duplicate Check

Describe the bug

As the title says, when I try to open another AlertDialog by calling page.show_dialog() in an AlertDialog in my project, for the sake of the interface's beauty, I close the previous dialog first and then show the new one. However, I find that this process can easily fail, but it is not necessarily unsuccessful.

Code sample

Code
import flet as ft


class AlertDialogTesting(ft.AlertDialog):
    def __init__(
        self,
        ref: ft.Ref | None = None,
    ):
        super().__init__(
            ref=ref,
        )
        self.title = "AlertDialog Example for Testing"
        self.content = ft.Text("Hello, World!")
        self.actions = [ft.TextButton("Open New Dialog", on_click=self.open_button_click)]

    async def open_button_click(self, event: ft.Event[ft.TextButton]):
        self.open = False
        self.update()
        self.page.show_dialog(AlertDialogTesting()) # will fail randomly


async def main(page: ft.Page):
    page.show_dialog(AlertDialogTesting())


if __name__ == "__main__":
    ft.run(main)

To reproduce

  1. Run the demo code
  2. Click "Open New Dialog" button
  3. There is a probability that you will notice that the dialog box cannot be opened normally

Expected behavior

The new dialog is opened steadily after the old dialog is closed.

Screenshots / Videos

Captures
Flet.2025-10-07.08-26-50.mp4

Operating System

Windows

Operating system details

Windows 11 24H2 (26100.6584)

Flet version

v0.70.0.dev6214

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
uv run flet run dialog.py

Additional details

No response

Metadata

Metadata

Assignees

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