Skip to content

[BUG] PopupV2 background overlay remains visible after popup is closed through navigation #2923

@Bamich

Description

@Bamich

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

In some cases on Android, I noticed that the popup's background overlay wouldn't always hide along with its popup when navigating between pages, blocking the entire application, CanBeDismissedByTappingOutsideOfPopup does not matter.

iOS has not been tested yet at the moment.

The simplest case is to call PopToRootAsync 1 frame after calling ShowPopup, the popup's background overlay will stay on top forever.

private void OnClicked(object? sender, EventArgs e)
	{
		Dispatcher.DispatchAsync(async () =>
		{
			// Be sure to specify the background color to see the overlay.
			var options = new PopupOptions()
			{
				PageOverlayColor = Colors.Green
			};

			// It doesn't matter what to show.
			var view = new Label
			{
				Text = "Tap to dismiss this popup",
				BackgroundColor = Colors.Red
			};

			// 1. Show the popup without waiting for it to close
			Shell.Current.ShowPopup(view, options);

			// 2. Wait for 1 frame.
			await Task.Yield();

			// 3. Finally, pop to root. The animated flag does not matter.
			await Shell.Current.Navigation.PopToRootAsync(false);

			/* 
			 * Now the popup itself is gone, but we see it's green overlay.
			 * The model stack is empty! Optionaly we can navigate to another page 
			 * in the regular navigation stack and see that the page has changed 
			 * under overlay. Essentially, the app is frozen and won't respond to touch.
			*/
			await Shell.Current.Navigation.PushAsync(new Page1());
		});
	}

Expected Behavior

The overlay hides along with its popup, thereby not blocking the application.

Steps To Reproduce

  1. Open and debug on Android sample app: https://github.com/Bamich/popup-v2-overlay-bug
  2. Click the button

Link to public reproduction project repository

https://github.com/Bamich/popup-v2-overlay-bug

Environment

- .NET MAUI CommunityToolkit: 12.2.0
- .NET MAUI: 9.0.120
- OS: Android, API 33

Actual behaviour

Screen_Recording_20251030_141527.mp4

Expected behaviour

Screen_Recording_20251030_141741.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions