Skip to content

[Android][Material 3] Fix Shell navigation bar background color not applied - #39660

Merged
kubaflo merged 1 commit into
dotnet:net11.0from
HarishwaranVijayakumar:fix-39599
Oct 26, 2026
Merged

kubaflo merged 1 commit into
dotnet:net11.0from
HarishwaranVijayakumar:fix-39599

Conversation

@HarishwaranVijayakumar

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • On Android with Material 3 enabled, ShellBackgroundColor no longer colors the navigation toolbar . Both direct assignments and styles are affected.

Root Cause

Description of Change

Bug fix:

  • Updated the condition in ToolbarExtensions.cs so that the bar background is set when either Material3 is not enabled or when UseMauiAndroidSystemBarBackgrounds is not enabled. This ensures the navigation bar background color is applied correctly on Android.

Testing improvements:

  • Added a new test case Issue39599 in TestCases.HostApp to manually verify that the navigation bar background color is blue and the title color is white.
  • Added an automated UI test for Issue39599 in TestCases.Shared.Tests to verify that the Shell background color is applied as expected on Android.

Issues Fixed

Fixes #39599

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Before After

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39660

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39660"

@HarishwaranVijayakumar
HarishwaranVijayakumar marked this pull request as ready for review October 26, 2026 12:31
Copilot AI balanced review requested due to automatic review settings October 26, 2026 12:31
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Oct 26, 2026
@azure-pipelines

This comment has been minimized.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@HarishwaranVijayakumar! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

No concrete defects were identified, but native Android rendering and relevant CI/UI-test results remain unverified.

No open issues 🎉

What changed in this PR

Restores Android Shell toolbar background colors when Material 3 is enabled without MAUI system-bar backgrounds, addressing the regression reported in #39599 after #38396.

Changes:

  • Enables direct toolbar coloring when MAUI system-bar backgrounds are disabled, preserving the existing AppBar path when both features are enabled.
  • Adds a Shell reproduction page and an Android Material 3 screenshot test.
File Description
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue39599.cs Adds an Android screenshot test for Shell background coloring.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue39599.cs Adds a Shell page with a blue toolbar background and white title.
src/​Controls/​src/​Core/​Platform/​Android/​Extensions/​ToolbarExtensions.cs Restores direct toolbar coloring when system-bar backgrounds are disabled.

Review effort: Balanced

@github-actions github-actions Bot added area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/android labels Oct 26, 2026
@sheiksyedm
sheiksyedm requested a review from kubaflo October 26, 2026 12:44
@sheiksyedm sheiksyedm linked an issue Oct 26, 2026 that may be closed by this pull request
@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 26, 2026
@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 1 finding

Reviewed commit 4198848.

See inline comments for details.

public void ShellBackgroundColorIsApplied()
{
App.WaitForElement("BackgroundColorLabel");
VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(2));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[moderate] Regression Prevention and Test Coverage - Add a discriminating regression assertion for Material 3 with MAUI system-bar backgrounds enabled, where direct toolbar tinting must remain skipped. This screenshot covers the disabled-system-bars case only. The existing Shell and NavigationPage *PreservesMaterial3AppBarLiftOnScrollStyling tests inspect the parent AppBar, including its lifted color, but do not check whether the child toolbar is tinted over it. Consequently, removing the guard entirely would still satisfy these assertions while hiding the AppBar highlight, the failure fixed by #38396/#37844. In the both-enabled configuration, assert that the toolbar remains untinted or check the visible toolbar color after lifting.

@MauiBot

MauiBot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@HarishwaranVijayakumar — existing-test verification for commit 4198848f.

Result FAILED Platform Android Commit 4198848f


🧪 Gate analysis — click to expand

❌ Failed. The selected tests did not meet the expected outcomes. Inspect the evidence before changing the test or fix.

🖥 UI tests
Test group Without fix With fix
Issue39599 ✅ Failed as expected (1417s) ❌ Failed (1481s)
Execution log excerpts

Without fix Issue39599

     at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay, Nullable`1 retryTimeout, Int32 cropLeft, Int32 cropRight, Int32 cropTop, Int32 cropBottom, Double tolerance) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 299
   at Microsoft.Maui.TestCases.Tests.Issues.Issue39599.ShellBackgroundColorIsApplied() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue39599.cs:line 21
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

With fix Issue39599

     at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay, Nullable`1 retryTimeout, Int32 cropLeft, Int32 cropRight, Int32 cropTop, Int32 cropBottom, Double tolerance) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 299
   at Microsoft.Maui.TestCases.Tests.Issues.Issue39599.ShellBackgroundColorIsApplied() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue39599.cs:line 21
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

PR head: 4198848f.

Without-fix baseline: 0e0f868d.

@MauiBot MauiBot added s/agent-gate-failed AI could not verify tests catch the bug and removed s/agent-review-in-progress AI review is currently running for this PR labels Oct 26, 2026
@kubaflo
kubaflo merged commit 0b49404 into dotnet:net11.0 Oct 26, 2026
65 of 179 checks passed
@kubaflo

kubaflo commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

/backport to release/11.0.1xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

kubaflo added a commit that referenced this pull request Oct 26, 2026
…39665) (#39670)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Manual backport of #39665 (commit
e440e02) to the explicitly requested
.NET 11 GA branch, `release/11.0.1xx`, after the automated backport
conflicted.

Create Android file-backed MediaPicker recovery fixtures in external
cache rather than private app storage, track the created files, and
delete them during fixture disposal. Existing private-storage rejection
tests remain unchanged. The resulting MediaPicker test file is
byte-for-byte identical to the source commit.

**Conflict adaptation:** GA does not contain
`GroupedCollectionViewEmptyViewTracksGroups`,
`GroupedCollectionViewEmptyViewTracksGroups2`, or their shared helper.
The source's `DynamicallyAccessedMembers(PublicConstructors)` annotation
therefore has no applicable target. Keep `CollectionViewTests.iOS.cs`
unchanged rather than importing unrelated CollectionView tests or
product changes.

**Validation:**
- `git diff --cached --check` — passed before commit.
- `git diff --exit-code e440e02 --
src/Essentials/test/DeviceTests/Tests/Android/MediaPickerRecovery_Tests.cs`
— passed; exact source file preserved.
- `git diff --exit-code HEAD --
src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.iOS.cs`
— passed before commit; GA file unchanged.
- `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src
--exclude-diagnostics CA1822 --include
src/Essentials/test/DeviceTests/Tests/Android/MediaPickerRecovery_Tests.cs
--verbosity quiet` — passed.
- `pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1
-Project Essentials -Platform android -BuildOnly` — blocked by missing
prerequisite MSBuild task outputs.
- `dotnet build Microsoft.Maui.BuildTasks.slnf --verbosity quiet` —
failed with NETSDK1140: GA references iOS/MacCatalyst 27.0, but the
installed preview workloads support 26.5. No device tests ran; runtime
validation remains for CI.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Backports #39665 for the Android MediaPicker recovery tests. No separate
issue is closed by this backport. #39660 is handled independently by
#39668 and is not included here.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: praveenkumarkarunanithi <100338903+praveenkumarkarunanithi@users.noreply.github.com>
kubaflo pushed a commit that referenced this pull request Oct 26, 2026
…kground color not applied (#39668)

Backport of #39660 to release/11.0.1xx

/cc @kubaflo @HarishwaranVijayakumar

Co-authored-by: HarishwaranVijayakumar <harishwaran.vijayakumar@syncfusion.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 26, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 4198848f Deployed Oct 26, 2026 by HarishwaranVijayakumar via conclusion #2508
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-gate-failed AI could not verify tests catch the bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell Navigation Bar Background Color Wrong

4 participants