[iOS,Windows] Fix navigation bar colors not resetting when switching ShellContent#33228
Conversation
There was a problem hiding this comment.
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 |
StephaneDelcroix
left a comment
There was a problem hiding this comment.
✅ Approved
Code Review Summary
Issue: Navigation bar colors persist when switching between ShellContent items (#33227)
Verified
- ✅ Code compiles successfully
- ✅ All 286 Shell-related unit tests pass
- ✅ ShellAppearance unit tests pass
- ✅ Code changes are minimal and surgical
iOS Fix Analysis
The fix correctly extends ResetAppearance() to also reset the iOS 13+ UINavigationBarAppearance by calling UpdateiOS13NavigationBarAppearance(controller, null). When appearance is null, a fresh default appearance is created with ConfigureWithOpaqueBackground(), properly resetting all colors.
Windows Fix Analysis
The fix correctly clears the toolbar title foreground when brush is null using ClearValue(CommandBar.ForegroundProperty), reverting to the default/inherited value.
Test Coverage
- HostApp test page with proper reproduction scenario
- NUnit UI test with screenshot verification
- Snapshots for all 4 platforms (iOS, Mac, Android, Windows)
LGTM! 🚀
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
…ShellContent (#33228) ### 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 - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #33227 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/0665c21a-f3b9-44e1-bb95-05678560ac73"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/29758b20-8bb4-4393-8936-5b7ccd06aab8">) | | Before Issue Fix | After Issue Fix | |----------|----------| | <video width="300" height="600" src="https://github.com/user-attachments/assets/3fd239fe-1b21-4ddb-8982-ed4939b47ab9"> | <video width="300" height="600" src="https://github.com/user-attachments/assets/f87c760e-3d24-4a53-b96c-1bf23b818482">) |
## What's Coming .NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 16 commits with various improvements, bug fixes, and enhancements. ## Checkbox - [Android] Implement material3 support for CheckBox by @HarishwaranVijayakumar in #33339 <details> <summary>🔧 Fixes</summary> - [Implement Material3 Support for CheckBox](#33338) </details> ## CollectionView - [Android] Fixed EmptyView doesn’t display when CollectionView is placed inside a VerticalStackLayout by @NanthiniMahalingam in #33134 <details> <summary>🔧 Fixes</summary> - [CollectionView does not show an EmptyView template with an empty collection](#32932) </details> ## Essentials - [Windows]Fix NullReferenceException in OpenReadAsync for FileResult created with full path by @devanathan-vaithiyanathan in #28238 <details> <summary>🔧 Fixes</summary> - [[Windows] FileResult(string fullPath) not initialized properly](#26858) </details> ## Image - Fix Glide IllegalArgumentException in MauiCustomTarget.clear() for destroyed activities by @jfversluis via @Copilot in #29780 <details> <summary>🔧 Fixes</summary> - [java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity - glide](#29699) </details> ## Label - [Android] Fix for Label WordWrap width issue causing HorizontalOptions misalignment by @praveenkumarkarunanithi in #33281 <details> <summary>🔧 Fixes</summary> - [[Android] Unexpected Line Breaks in Android, Label with WordWrap Mode Due to Trailing Space.](#31782) - [Label not sized correctly on Android](#27614) </details> - Fix to Improve Flyout Accessibility by Adjusting UITableViewController Labels by @SuthiYuvaraj in #31619 <details> <summary>🔧 Fixes</summary> - [Navigation section present under hamburger are programmatically define as table :A11y_.NET maui_User can get all the insights of Dashboard_Devtools](#30894) </details> ## Mediapicker - [Regression][iOS] Fix MediaPicker PickPhotosAsync getting file name in contentType property by @devanathan-vaithiyanathan in #33390 <details> <summary>🔧 Fixes</summary> - [[iOS] MediaPicker PickPhotosAsync getting file name in contentType property](#33348) </details> ## Navigation - Fix handler not disconnected when removing non visible pages using RemovePage() by @Vignesh-SF3580 in #32289 <details> <summary>🔧 Fixes</summary> - [NavigationPage.Navigation.RemovePage() fails to disconnect handlers when removing pages, unlike ContentPage.Navigation.RemovePage()](#32239) </details> ## Picker - [Android] Fix Picker IsOpen not reset when picker is dismissed by @devanathan-vaithiyanathan in #33332 <details> <summary>🔧 Fixes</summary> - [[Android] Picker IsOpen not reset when picker is dismissed](#33331) </details> ## Shell - [iOS & Catalyst ] Fixed IsEnabled property should work on Tabs by @SubhikshaSf4851 in #33369 <details> <summary>🔧 Fixes</summary> - [[Catalyst] TabBarBackgroundColor, TabBarUnselectedColor, and IsEnabled Not Working as Expected in Shell](#33158) </details> - [iOS,Windows] Fix navigation bar colors not resetting when switching ShellContent by @Vignesh-SF3580 in #33228 <details> <summary>🔧 Fixes</summary> - [[iOS, Windows] Shell Navigation bar colors are not updated correctly when switching ShellContent](#33227) </details> - [iOS] Fixed Shell navigation on search handler suggestion selection by @SubhikshaSf4851 in #33406 <details> <summary>🔧 Fixes</summary> - [[iOS] Clicking on search suggestions fails to navigate to detail page correctly](#33356) </details> ## Templates - Fix VoiceOver doesnot announces the State of the ComboBox by @SuthiYuvaraj in #32286 ## Xaml - [XSG][BindingSourceGen] Add support for CommunityToolkit.Mvvm ObservablePropertyAttribute by @simonrozsival via @Copilot in #33028 <details> <summary>🔧 Fixes</summary> - [[XSG] Add heuristic to support bindable properties generated by other source generators](#32597) </details> <details> <summary>📦 Other (2)</summary> - [XSG] Improve diagnostic reporting during binding compilation by @simonrozsival via @Copilot in #32905 - [Testing] Fixed Test case failure in PR 33574 - [01/19/2026] Candidate - 1 by @TamilarasanSF4853 in #33602 </details> **Full Changelog**: main...inflight/candidate
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