-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS,Windows] Fix navigation bar colors not resetting when switching ShellContent #33228
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 a bug where navigation bar colors incorrectly persist when switching between ShellContent items on iOS and Windows. When navigating from a page with custom navigation bar colors to a page without defined colors, the previous colors were not being cleared.
Key changes:
- iOS: Reset navigation bar appearance to default when no colors are specified
- Windows: Clear toolbar title foreground when brush is null to prevent color persistence
- Added comprehensive UI tests to verify the fix on both platforms
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Core/src/Platform/Windows/MauiToolbar.xaml.cs |
Clears the title foreground property when brush is null to prevent color persistence |
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellNavBarAppearanceTracker.cs |
Resets navigation bar appearance to default when appearance is null, preventing color carryover |
src/Controls/tests/TestCases.HostApp/Issues/Issue33227.cs |
Adds test application with two pages demonstrating the issue |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33227.cs |
Adds UI test to verify navigation bar colors reset correctly |
Issue details
When switching between ShellContent items, navigation bar colors from the previously displayed page are incorrectly applied to the next page, even when the next page does not define any navigation bar colors.
On iOS, background and title colors persist across pages.
On Windows, the issue is limited to TitleColor, which remains applied when navigating to an uncolored page.
Root cause
iOS:
Navigation bar appearance is applied via SetAppearance in ShellNavBarAppearanceTracker when colors are specified. However, when navigating to a page without defined colors, the appearance is not reset, causing previously applied colors to persist.
Windows:
The toolbar title foreground is updated only when a brush is provided. When switching to a page without a TitleColor, the previous brush is not cleared, so the title color remains.
Description of change
iOS:
Reset the navigation bar appearance to the default native appearance when no colors are specified, ensuring that colors from a previous page are not carried over.
Windows:
Clear the toolbar title foreground when the brush is null, allowing the title color to revert to the system default instead of retaining the previous color.
Tested the behavior in the following platforms
Issues Fixed
Fixes #33227
Screenshots
33227BeforeFix.mov
33227AfterFix.mov
TitleBefore.mp4
TitleAfter.mp4