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

Multiple dialogs (AlertDialog) will create a ghost dialog #1670

Closed
litalidev opened this issue Aug 4, 2023 · 5 comments
Closed

Multiple dialogs (AlertDialog) will create a ghost dialog #1670

litalidev opened this issue Aug 4, 2023 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@litalidev
Copy link

litalidev commented Aug 4, 2023

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.

image

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:

@gbrandt
Copy link

gbrandt commented Aug 4, 2023

I can confirm this, I see it a lot and had to do many work arounds to stop double clicks from opening two dialogs.

My work around is to always call close_dialog before I call open dialog, sleep for 0.2 seconds and then open the new dialog. The delay sucks but seems to prevent this issue.

@FeodorFitsner
Copy link
Contributor

I can also confirm that this annoying problem exists - faced it while working on Flet Studio app. It happens when quickly switching between alert dialogs or/and snack bars. Adding delay (to finish previous exit animation) between dialogs helps, but it's, of course, a hack. Will be working on fixing this bug.

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Aug 4, 2023
@daniethan
Copy link

Sometimes the AlertDialog shows up as a long white column with a dark background. Not showing the intended content. I experienced this in adroid while running the app on Flet Studio. Am still stuck.

@donolsch
Copy link

donolsch commented Oct 10, 2023

I can confirm I am facing the same issue when switching between two alert dialogs. Adding a delay fixed it. Thank you!

@FeodorFitsner
Copy link
Contributor

@donolsch could you provide a code to repro?

@FeodorFitsner FeodorFitsner added the status: working on it Working on a fix for the issue label Nov 14, 2023
@FeodorFitsner FeodorFitsner added this to the Flet v0.12.1 milestone Nov 14, 2023
@FeodorFitsner FeodorFitsner added done and removed status: working on it Working on a fix for the issue labels Nov 14, 2023
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* Dismiss drawers on page change

* Fixed routing regression

Fix flet-dev#2082

* ViewControl

* Bottom sheet to use control state

Fix flet-dev#2075

* AnimatedTransitionPage

* Remove old animated pages

* Flet version bumped to 0.12.1

* Added `BottomSheet. is_scroll_controlled` property

Allows expanding bottom sheet on the entire screen.
Close flet-dev#2087

* Fixed: close currently opened AlertDialog before opening a new one

Fix flet-dev#1670

* Added `BottomSheet.maintain_bottom_view_insets_padding` property

Close flet-dev#2010
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

5 participants