[.NET 11] Fix Material3 failures in net 11 branch - #37342
Merged
Conversation
Dhivya-SF4094
temporarily deployed
to
copilot-pat-pool
August 12, 2026 10:42 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37342Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37342" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Dhivya-SF4094
temporarily deployed
to
copilot-pat-pool
August 12, 2026 10:42 — with
GitHub Actions
Inactive
Dhivya-SF4094
temporarily deployed
to
copilot-pat-pool
August 12, 2026 10:43 — with
GitHub Actions
Inactive
Dhivya-SF4094
temporarily deployed
to
copilot-pat-pool
August 12, 2026 10:44 — with
GitHub Actions
Inactive
Dhivya-SF4094
had a problem deploying
to
copilot-pat-pool
August 12, 2026 10:46 — with
GitHub Actions
Failure
Dhivya-SF4094
temporarily deployed
to
copilot-pat-pool
August 12, 2026 10:46 — with
GitHub Actions
Inactive
sheiksyedm
marked this pull request as ready for review
August 13, 2026 11:29
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Android toolbar default foreground color resolution when Material 3 is enabled, aiming to fix screenshot test failures caused by pulling title/navigation icon colors from legacy AppCompat sources and by a hard-coded black/white fallback introduced in PR #35463.
Changes:
- For Material 3, resolves default toolbar title text and navigation icon colors from the theme’s
colorOnSurface. - Removes the intermediate hard-coded
GetDefaultForegroundColor()fallback from title/navigation color resolution. - Stops using the removed fallback for overflow icon color (now only
IconColor/BarTextColorinfluence it).
Suppressed comments (1)
src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs:279
context.GetThemeAttrColor(Resource.Attribute.colorOnSurface)returns0when the attribute isn’t found (src/Core/src/Platform/Android/ContextExtensions.cs:221-247). If Material3 is enabled via feature switch but the theme doesn’t definecolorOnSurface, this will set the navigation icon color to fully transparent. Recommend treating0as “not resolved” and falling back to the existingDrawerArrowDrawabledefault.
if (RuntimeFeature.IsMaterial3Enabled)
{
return context.GetThemeAttrColor(Resource.Attribute.colorOnSurface);
}
Comment on lines
+254
to
+258
| if (RuntimeFeature.IsMaterial3Enabled) | ||
| { | ||
| var colorContext = context is null | ||
| ? null | ||
| : ColorStateList.ValueOf(new global::Android.Graphics.Color(context.GetThemeAttrColor(Resource.Attribute.colorOnSurface))); |
kubaflo
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause
Cause PR #35463
Description of Change
GetDefaultForegroundColor()Was RemovedThe foreground color was not originally part of the toolbar fallback chain. The title text and navigation icon defaults previously relied directly on the theme-provided values (
Toolbar_titleTextColorandDrawerArrowDrawable).GetDefaultForegroundColor()was introduced later as an additional fallback in PR [Android] Make system chrome follow MAUI bar colors (opt-in) #35463, so removing it restores the original toolbar behavior.It returned hard-coded
Black/Whitevalues that do not represent the Material 3colorOnSurfacetonal color. This resulted in foreground colors that were inconsistent with the rest of the Material 3 toolbar.It took precedence over the theme-aware default in the fallback chain. Because it was evaluated earlier, it could short-circuit the resolution process and prevent the correct theme color from being applied.
Removing it allows the theme-provided value to remain authoritative —
colorOnSurfacefor Material 3 and the existing legacy theme default otherwise. This ensures the toolbar uses the correct platform/theme color and resolves the failing test.