Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

Fix AppBarLayout insets when FlyoutPage is pushed modally on Android

Summary

When a FlyoutPage is pushed modally, the AppBarLayout doesn't receive window insets, causing the navigation bar to render behind system UI elements.

Root Cause

Modal FlyoutPage hierarchy is ContainerView > DrawerLayout > NavigationRoot > AppBarLayout. When the listener is triggered for the ContainerView wrapper, the insets need to pass through to allow the CoordinatorLayout inside to handle them correctly.

Changes

  • GlobalWindowInsetListener.cs: Added early return for ContainerView to pass insets through to child views (7 lines added)
  • Issue32277.cs (TestCases.HostApp): Added UI test page with button to push FlyoutPage modally
  • Issue32277.cs (TestCases.Shared.Tests): Added UI test to verify AppBarLayout insets work correctly (restricted to Android and iOS)
// For ContainerView (e.g., modal FlyoutPage), pass insets through to child views
// This allows the CoordinatorLayout inside to handle insets correctly
if (v is ContainerView)
{
    return insets;
}

This minimal approach allows the standard inset handling to work correctly on the child CoordinatorLayout without any refactoring.

Testing

  • UI test Issue32277 validates the fix by pushing a FlyoutPage modally and using screenshot verification to ensure proper AppBarLayout insets
  • Test restricted to non-desktop platforms (Android and iOS) using #if ANDROID || IOS
  • Manual verification: Maui.Controls.Sample → Core → Modal → Push Modal Flyout Page

Fixes #32277

Original prompt

This section details on the original issue you should resolve

<issue_title>When a FlyoutPage is pushed Modally it doesn't inset the AppBarLayout</issue_title>
<issue_description>### Description

Currently when you push a FlyoutPage modally the navigationbar is not correctly being padded, this is most likely because the AppBarLayout isn't being found inside the GlobalWindowInsetListener

Reproduction

Run Maui.Samples
Navigate to Core => Modal
Push Flyout Page Modally</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@NirmalKumarYuvaraj NirmalKumarYuvaraj added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 4, 2025
Copilot AI changed the title [WIP] Fix AppBarLayout inset for modal FlyoutPage Fix AppBarLayout insets when FlyoutPage is pushed modally on Android Nov 4, 2025
Copilot finished work on behalf of NirmalKumarYuvaraj November 4, 2025 10:23
@NirmalKumarYuvaraj
Copy link
Contributor

@copilot , This issue occurs only if the flyout page is wrapped inside modal page. No issue if we directly load the FlyoutPage.

@NirmalKumarYuvaraj
Copy link
Contributor

@copilot , When a FlyoutPage is pushed modally, the listener is triggered for the ContainerView. Normally, insets are processed using a CoordinatorLayout-based approach. However, when the ContainerView becomes the root view of the modal flyout, the insets for the CoordinatorLayout are skipped.
Adding a condition like if (v is ContainerView) return insets; fixes the issue and ensures that insets are applied correctly.

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot , When a FlyoutPage is pushed modally, the listener is triggered for the ContainerView. Normally, insets are processed using a CoordinatorLayout-based approach. However, when the ContainerVie...

Implemented the ContainerView early return approach in 3622f9c. This simpler solution passes insets through to child views, allowing the CoordinatorLayout to handle them correctly without needing recursive search.

Copilot finished work on behalf of NirmalKumarYuvaraj November 5, 2025 10:36
@NirmalKumarYuvaraj
Copy link
Contributor

@copilot , Remove the unwanted refactoring changes.

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot , Remove the unwanted refactoring changes.

Removed the unwanted refactoring in d367acb. The PR now contains only minimal changes: 7 lines added to GlobalWindowInsetListener.cs for the ContainerView fix, and 34 lines added to ModalTests.Android.cs for the test.

Copilot finished work on behalf of NirmalKumarYuvaraj November 5, 2025 11:44
@NirmalKumarYuvaraj
Copy link
Contributor

@copilot , The test case added seems incorrect. Create a UI Test case for this scenario and with Issue32277 as IssueID. The test page Issue32277 should be a content page. That should contain a button. In the button click, Push the flyoutPage modally. Restrict this test case in desktop platforms.
Example code:

public partial class Issue32277 : ContentPage
{
	public Issue32277()
	{
        Button button = new Button
		{
			Text = "Go to Issue32277 Page"
		};
		button.Clicked += async (s, e) =>
		{
			await Navigation.PushModalAsync(new Issue32277_FlyoutPage());
		};
		Content = new StackLayout
		{
			Children =
			{
				button
			}
		};
	}
}

public class Issue32277_FlyoutPage : FlyoutPage
{
	public Issue32277_FlyoutPage()
	{
		Flyout = new ContentPage
		{
			Title = "Flyout",
			Content = new StackLayout
			{
				Children =
				{
					new Label { Text = "This is the flyout page." }
				}
			}
		};

		Detail = new NavigationPage(new ContentPage());
	}
}

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot , The test case added seems incorrect. Create a UI Test case for this scenario and with Issue32277 as IssueID. The test page Issue32277 should be a content page. That should contain a button....

Replaced the DeviceTest with UI Test in 61460bb. Created Issue32277.cs in both TestCases.HostApp (test page with button to push FlyoutPage modally) and TestCases.Shared.Tests (UI test restricted to Android and iOS platforms using #if ANDROID || IOS).

Copilot finished work on behalf of NirmalKumarYuvaraj November 5, 2025 12:13
@@ -0,0 +1,33 @@
#if ANDROID || IOS // Exclude desktop platforms (Windows, MacCatalyst)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , replace App.WaitForElement("DetailLabel", "Detail page should be visible with proper insets"); with VerifyScreenshot().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in e3adbcc. Replaced App.WaitForElement("DetailLabel", "Detail page should be visible with proper insets") with VerifyScreenshot() for visual verification of proper AppBarLayout insets.

Copilot finished work on behalf of NirmalKumarYuvaraj November 5, 2025 12:21
@NirmalKumarYuvaraj NirmalKumarYuvaraj marked this pull request as ready for review November 5, 2025 12:38
Copilot AI review requested due to automatic review settings November 5, 2025 12:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where modal FlyoutPages don't receive proper window insets on Android, causing the AppBarLayout to render behind system UI elements. The fix adds a special case in the GlobalWindowInsetListener to pass insets through to child views when the view is a ContainerView.

Key changes:

  • Modified window inset handling to allow ContainerView to pass insets to its children
  • Added UI test coverage for modal FlyoutPage scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/Android/GlobalWindowInsetListener.cs Added check to pass insets through ContainerView to child views (e.g., CoordinatorLayout)
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32277.cs Added NUnit test to verify modal FlyoutPage receives proper AppBarLayout insets
src/Controls/tests/TestCases.HostApp/Issues/Issue32277.cs Added HostApp UI page demonstrating modal FlyoutPage inset issue

@@ -0,0 +1,33 @@
#if ANDROID || IOS // Exclude desktop platforms (Windows, MacCatalyst)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This platform directive unnecessarily restricts the test. According to the UI Testing Guidelines (CodingGuidelineID: 1000002), tests should run on all applicable platforms by default unless there is a specific technical limitation. The HostApp code-behind specifies PlatformAffected.Android, which suggests this is primarily an Android issue, but the test infrastructure will handle platform filtering automatically. Unless FlyoutPage modal navigation has known issues on iOS/Windows/MacCatalyst that would cause the test to fail, this directive should be removed to allow the test to run on all platforms.

Copilot generated this review using guidance from repository custom instructions.
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 10.0 SR1 milestone Nov 7, 2025
@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Nov 7, 2025
PureWeen
PureWeen previously approved these changes Nov 7, 2025
@github-project-automation github-project-automation bot moved this from Todo to Approved in MAUI SDK Ongoing Nov 7, 2025
@PureWeen PureWeen force-pushed the copilot/fix-flyoutpage-modal-inset branch from d8a69f2 to 88707e6 Compare November 7, 2025 20:41
@PureWeen
Copy link
Member

PureWeen commented Nov 7, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

PureWeen
PureWeen previously approved these changes Nov 7, 2025
@PureWeen
Copy link
Member

PureWeen commented Nov 7, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

  • this was fixed by a different PR but this PR has tests that are missing for validating this behavior

@PureWeen PureWeen merged commit 3d9d1ab into main Nov 10, 2025
164 checks passed
@PureWeen PureWeen deleted the copilot/fix-flyoutpage-modal-inset branch November 10, 2025 22:58
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

When a FlyoutPage is pushed Modally it doesn't inset the AppBarLayout

4 participants