Skip to content

Fixed Shell TitleView disappears when switching between tabs on Android #33469

Merged
kubaflo merged 11 commits intodotnet:inflight/currentfrom
KarthikRajaKalaimani:fix-33304
Mar 19, 2026
Merged

Fixed Shell TitleView disappears when switching between tabs on Android #33469
kubaflo merged 11 commits intodotnet:inflight/currentfrom
KarthikRajaKalaimani:fix-33304

Conversation

@KarthikRajaKalaimani
Copy link
Contributor

@KarthikRajaKalaimani KarthikRajaKalaimani commented Jan 12, 2026

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:

Shell TitleView disappears when switching between tabs on Android (regression from MAUI 9.0.30).

Root Cause:

When switching tabs, we reuses fragments by hiding/showing them if the ShellNavigationSource is ShellSectionChanged in ShellItemRendererBase class(line number 235 to 242). When a fragment becomes visible again, the TitleView handler update isn't automatically triggered, leaving the TitleView invisible.

Description of Change:

Updated TitleView of the shellToobar when fragment becomes visible after being hidden, ensuring TitleView appears when switching back to a tab.

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac

Reference:

N/A

Issues Fixed:

Fixes #33304

Screenshots

Before After
Screen.Recording.2026-01-12.at.11.31.08.AM.mov
Screen.Recording.2026-01-12.at.11.34.16.AM.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 12, 2026
@dotnet-policy-service
Copy link
Contributor

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 12, 2026
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added platform/android area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels Jan 12, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review January 16, 2026 14:05
Copilot AI review requested due to automatic review settings January 16, 2026 14:05
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 a regression in .NET MAUI 9.0.30 where Shell TitleView disappears when switching between tabs on Android. The fix ensures that when a fragment becomes visible after being hidden (during tab switching), the TitleView is properly refreshed.

Changes:

  • Added OnHiddenChanged override in ShellSectionRenderer to update TitleView when fragment becomes visible
  • Stored Toolbar reference as field to enable TitleView updates during fragment visibility changes
  • Added UI test to verify TitleView persists when switching tabs

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
ShellSectionRenderer.cs Stores Toolbar reference as _shellToolbar field and overrides OnHiddenChanged to update TitleView when fragment becomes visible after tab switch
PublicAPI.Unshipped.txt Documents the new public API method OnHiddenChanged override for Android
Issue33304.cs (HostApp) Implements test page with Shell containing multiple tabs and a TitleView to reproduce the issue
Issue33304.cs (Tests) Adds automated UI test that switches tabs and verifies TitleView persists

@kubaflo
Copy link
Contributor

kubaflo commented Jan 25, 2026

🤖 AI Summary

📊 Expand Full Review4114040 · Renamed test method
🔍 Pre-Flight — Context & Validation
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d

Issue: #33304 - [Android] TitleView defined in Shell is lost when changing tabs
PR: #33469 - Fixed Shell TitleView disappears when switching between tabs on Android
Author: KarthikRajaKalaimani (Syncfusion partner)
Platforms Affected: Android only
Regression: Yes - regressed in MAUI 9.0.30 (worked in 9.0.22)

Issue Summary

On Android, Shell.TitleView displays correctly on first tab but disappears when switching to the second tab, then reappears on the third tab. Regression from MAUI 9.0.30.

Root Cause (from PR): When switching tabs, fragments are reused via hide/show. When a fragment becomes visible again via OnHiddenChanged, the TitleView handler update isn't automatically triggered.

Files Changed

  • Fix: src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs (+17, -4)
  • API: src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt (+1)
  • Test HostApp: src/Controls/tests/TestCases.HostApp/Issues/Issue33304.cs (+97)
  • Test NUnit: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33304.cs (+27)

PR Discussion Summary

All addressed
Addressed in commit "Set _shellToolbar to null on Destroy method"

  • PureWeen review status: CHANGES_REQUESTED (still pending re-review after fixes were applied)
  • Prior agent review: All 4 phases completed on an earlier commit (7cb9cee) - APPROVE recommended

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (prior) Post delayed UpdateTitleView() in ShellToolbarTracker.OnShellNavigated() when ` FAIL ShellToolbarTracker.cs Navigation event fires before fragment visibility change ShellSectionChanged`
PR PR #33469 Override OnHiddenChanged to update TitleView when fragment becomes PENDING (Gate) ShellSectionRenderer.cs (+17), PublicAPI.Unshipped.txt (+1) Original PR, all feedback addressed visible

Issue: #33304 - [Android] TitleView defined in Shell is lost when changing tabs
PR: #33469 - Fixed Shell TitleView disappears when switching between tabs on Android
Platforms Affected: Android
Files Changed: 2 implementation, 2 test

Key Findings

  • The linked issue is an Android-only regression introduced after MAUI 9.0.22 and reproducible from 9.0.30 onward; the original repro specifically notes the TitleView disappears on the second tab and reappears on the third.
  • The PR changes one Android Shell compatibility renderer plus its Android PublicAPI entry, and adds a HostApp + shared UI test pair for Issue33304.
  • Prior review feedback focused on null-safety, nameof(Toolbar.TitleView), and clearing _shellToolbar in Destroy(); those comments are resolved in the current diff.
  • A prior agent review exists in PR comments and previously recommended approval on an earlier commit after reporting Gate pass and multiple alternative fixes.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #33469 Override OnHiddenChanged to refresh Toolbar.TitleView when a hidden Android Shell section becomes visible again ⏳ PENDING (Gate) src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs, src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Original PR; UI test coverage added via Issue33304 HostApp + shared test files

🚦 Gate — Test Verification
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d

Result: ✅ PASSED
Platform: android
Mode: Full Verification (RequireFullVerification: true)

  • Tests FAIL without fix ✅
  • Tests PASS with fix ✅

Test: Issue33304Test
Fix Files Verified:

  • src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs
  • src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt

Gate Result: ✅ PASSED

Platform: android
Mode: Full Verification

  • Tests FAIL without fix: ✅
  • Tests PASS with fix: ✅

Evidence: pwsh .github/skills/verify-tests-fail-without-fix/scripts/verify-tests-fail.ps1 -Platform android -TestFilter "Issue33304" -RequireFullVerification


🔧 Fix — Analysis & Comparison
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d

Result: ✅ PASSED
Platform: android
Mode: Full Verification (RequireFullVerification: true)

  • Tests FAIL without fix ✅
  • Tests PASS with fix ✅

Test: Issue33304Test
Fix Files Verified:

  • src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs
  • src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Refresh TitleView from ShellItemRendererBase.HandleFragmentUpdate after ShellSectionChanged by forcing pending transactions and calling internal refresh helpers ✅ PASS 3 files Parent-driven lifecycle alternative; broader plumbing than PR fix
2 try-fix (claude-sonnet-4.6) Post a refresh callback from ShellItemRendererBase after fragment commit and call an internal ShellSectionRenderer.RefreshTitleView() helper ✅ PASS 2 files Relies on concrete ShellSectionRenderer cast and looper ordering
3 try-fix (gpt-5.3-codex) Rebind the toolbar tracker during ShellSectionChanged by resetting Page through a new ShellSectionRenderer.RefreshToolbarForCurrentItem() helper ✅ PASS 2 files Uses tracker/page rebinding rather than direct handler update
4 try-fix (gemini-3-pro-preview) In OnHiddenChanged, toggle _toolbarTracker.Page null→current page to force the tracker to re-run UpdateTitleView() ✅ PASS 2 files Reuses tracker abstraction but still depends on the same lifecycle callback as PR
5 try-fix (claude-opus-4.6 R2) Same-page tracker refresh variants entirely inside ShellToolbarTracker ❌ FAIL 1 file Repeated UpdateValue(nameof(Toolbar.TitleView)) remained effectively idempotent
6 try-fix (claude-sonnet-4.6 R2) Native Toolbar.Android.Container reclaim logic that re-applies TitleView when its child was stolen during tab switches ✅ PASS 1 file Deeper native-view fix outside Shell-specific code
7 try-fix (gpt-5.3-codex R2) Toolbar-local visibility/self-heal changes inside Toolbar.UpdateTitleView() ❌ FAIL 1 file Re-showing native view state alone did not restore TitleView after fragment reuse
PR PR #33469 Override OnHiddenChanged in ShellSectionRenderer and call _shellToolbar.Handler.UpdateValue(nameof(Toolbar.TitleView)) when visible again ✅ PASS (Gate) 2 files Original PR

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 1 Yes Tracker-only same-page refresh inside ShellToolbarTracker
claude-sonnet-4.6 1 Yes Native toolbar re-attach / reclaim on Android view lifecycle
gpt-5.3-codex 1 Yes Self-healing visibility in Toolbar.UpdateTitleView()
gemini-3-pro-preview 1 No NO NEW IDEAS
claude-opus-4.6 2 No NO NEW IDEAS
claude-sonnet-4.6 2 No NO NEW IDEAS
gpt-5.3-codex 2 No NO NEW IDEAS
gemini-3-pro-preview 2 No NO NEW IDEAS

Exhausted: Yes
Selected Fix: PR's fix — It is the best balance of correctness and scope: Android-specific, direct, minimal, and validated by Gate. The other passing candidates either add broader Shell coordination, depend on concrete renderer casts, or change generic toolbar/container behavior beyond the reported regression.


📋 Report — Final Recommendation
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d

✅ Final Recommendation: APPROVE

Summary

PR #33469 fixes a regression (introduced in MAUI 9.0.30) where Shell.TitleView disappears when switching between tabs on Android. The fix is minimal, well-targeted, and all reviewer feedback has been addressed.

Root Cause

When switching Shell tabs on Android, fragments are reused via HideEx()/ShowEx() calls in ShellItemRendererBase.HandleFragmentUpdate (lines 235-242). When a fragment becomes visible again, OnHiddenChanged(false) fires, but the Toolbar.TitleView handler update was never triggered — leaving the TitleView invisible. This is an Android-specific issue tied to fragment lifecycle.

Fix Quality

The PR overrides OnHiddenChanged in ShellSectionRenderer to explicitly update the TitleView handler when the fragment becomes visible:

public override void OnHiddenChanged(bool hidden)
{
    base.OnHiddenChanged(hidden);
    if (!hidden && _shellToolbar?.Handler != null)
    {
        _shellToolbar.Handler.UpdateValue(nameof(Toolbar.TitleView));
    }
}

Why this is the optimal fix:

  • Minimal footprint: 11 lines of logic in 1 Android-specific file
  • Correct lifecycle timing: OnHiddenChanged fires at the exact moment fragment visibility changes
  • Directly updates the broken property (TitleView) with proper null safety and nameof() type safety
  • 5 alternative approaches (try-fix) were explored — all passing but with higher complexity or risk
  • 1 alternative (removing guard in ShellToolbarTracker) confirmed ❌ — guards are necessary

Try-Fix Summary

6 alternatives explored:

  • ✅ Interface method on IShellObservableFragment (more complex, adds public API)
  • ✅ ShellSection.Appearing event subscription (cross-platform event for Android-specific issue)
  • ✅ Detach/Attach instead of Hide/Show (higher regression risk)
  • ✅ RefreshToolbarForSection() via page null→current (more indirect)
  • ✅ OnHiddenChanged with tracker page reset (variant of PR's approach)
  • ❌ Remove guard in ShellToolbarTracker.UpdateTitleView() (guards are necessary)

Selected Fix: PR's fix — simplest, most direct, lowest risk

PR Metadata Review

Title: Minor update recommended

  • Current: Fixed Shell TitleView disappears when switching between tabs on Android (trailing space)
  • Suggested: [Android] Shell: Fix TitleView disappearing when switching between tabs

Description: Good — has NOTE block, root cause, fix description, tested platforms, issue link. Missing "What NOT to Do" section for future agents (guard removal approach doesn't work).

Gate Result

✅ PASSED on Android:

  • Tests FAIL without fix (bug reproduced)
  • Tests PASS with fix

Minor Suggestions (Non-blocking)

  1. Fix trailing space in title, add [Android] prefix
  2. Add "What NOT to Do" to description: Don't remove GetCurrentShellPage() == Page guard in ShellToolbarTracker — guards are necessary
  3. Consider testing Settings tab in test (matches original 3-tab repro) — current test is sufficient

✅ Final Recommendation: APPROVE

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Android-only regression from issue #33304; prior review feedback resolved
Gate ✅ PASSED Android full verification: tests fail without fix and pass with fix
Try-Fix ✅ COMPLETE 7 candidates evaluated, 5 passing; PR fix selected after exhaustion round
Report ✅ COMPLETE

Summary

PR #33469 fixes the Android Shell regression where Shell.TitleView disappears when switching tabs. The added UI test was validated in both directions on Android, and the fix remained the best option after evaluating seven alternative approaches.

A local review-branch quirk surfaced unrelated squashed files that were not part of the GitHub PR diff, so the try-fix comparison was intentionally constrained to the actual Android Shell issue scope from GitHub metadata and the verified Issue33304 test path.

Root Cause

For ShellNavigationSource.ShellSectionChanged, Android reuses existing fragments by hiding and showing them. When a previously hidden ShellSectionRenderer becomes visible again, the toolbar TitleView is not refreshed automatically, so the shared TitleView no longer appears on the visible tab.

Fix Quality

The PR fixes the problem in the narrowest correct place: ShellSectionRenderer.OnHiddenChanged(false). That hook fires exactly when the previously hidden fragment becomes visible again, and the fix directly re-applies Toolbar.TitleView with proper null-safety.

Compared with the passing alternatives, the PR avoids extra Shell coordination code, avoids concrete renderer casts in parent orchestration, and avoids changing generic toolbar/container behavior for an Android Shell-specific regression. That makes it the lowest-risk and clearest fix of the set.


📋 Expand PR Finalization Review

PR #33469 Finalization Review

Title

⚠️ Needs update.

Current: Fixed Shell TitleView disappears when switching between tabs on Android

Recommended: [Android] Shell: Refresh TitleView when switching back to a tab

Why:

  • Uses the repo's preferred searchable format: platform + component + behavior.
  • Drops the trailing space and the generic Fixed wording.
  • Describes the implemented behavior instead of restating the issue in prose.

Description

✅ Good foundation, but it should be tightened rather than replaced.

Keep:

  • The required NOTE block is already present.
  • The current root-cause explanation is directionally correct.
  • The description already points at the fragment hide/show behavior that causes the regression.

Recommended edits:

  • Fix wording/typos:
    • reuse fragments or reuses fragments instead of awkward wording
    • shellToolbar instead of shellToobar
  • Make the implementation description more explicit:
    • Mention that ShellSectionRenderer.OnHiddenChanged(bool hidden) now refreshes nameof(Toolbar.TitleView) when an existing tab fragment becomes visible again.
    • Mention that the renderer now keeps a Toolbar reference (_shellToolbar) so the TitleView handler can be updated on re-show.
  • Mention the added regression coverage:
    • src/Controls/tests/TestCases.HostApp/Issues/Issue33304.cs
    • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33304.cs
  • Fix the platform testing section:
    • This is an Android-specific fix and Android-specific UI regression test. Do not mark Windows/iOS/Mac as tested unless they were actually validated.
  • Normalize the issue link formatting to Fixes #33304.

Suggested revised Description of Change:

When Shell switches tabs on Android, it can reuse existing fragments by hiding and showing them instead of recreating them. In that path, the TitleView handler is not automatically refreshed when a previously hidden tab becomes visible again, so the TitleView disappears.

This change stores the Shell toolbar instance on ShellSectionRenderer and refreshes nameof(Toolbar.TitleView) from OnHiddenChanged(bool hidden) when the fragment becomes visible again. A UI regression test was also added to verify that the TitleView remains visible after switching away from and back to a tab.

Code Review Findings

✅ Looks good

  • The implementation is small and targeted to the Android Shell fragment lifecycle path that matches the reported regression.
  • Prior review concerns appear to be addressed:
    • _shellToolbar is now nulled in Destroy().
    • OnHiddenChanged guards against a missing handler.
    • nameof(Toolbar.TitleView) is used instead of a magic string.
  • The PR includes a regression UI test, not just the renderer fix.
  • PublicAPI.Unshipped.txt was updated for the new override, which is consistent with repo requirements.

🔴 Critical issues

  • None found in the changed files.

🟡 Suggestions

  • The description should explicitly mention the new UI regression test and avoid claiming non-Android platform validation unless that actually happened.
  • Consider adding an _disposed guard at the start of OnHiddenChanged(bool hidden). The null check on _shellToolbar helps, but other handlers in this renderer already use _disposed defensively around fragment lifecycle timing.
  • Consider extending the UI test to visit the third tab as well, since the repro description mentions the TitleView disappearing on one tab transition pattern across multiple tabs. The current test still exercises the core hide/show path, but broader navigation coverage would better match the issue narrative.

Informational notes

  • Current PR status is still not fully green: GitHub check runs show maui-pr and Build Analysis failing at the time of review.
  • The PR's current mergeable state is blocked in GitHub metadata. This review did not investigate the failing checks or merge block reason.

Overall assessment

The code changes themselves look mergeable from a code-review perspective. The main follow-up is PR metadata cleanup: update the title to the standard format, tighten the description so it precisely matches the implementation, and correct the platform testing claims.

kubaflo
kubaflo previously approved these changes Jan 25, 2026
@PureWeen
Copy link
Member

/rebase

@rmarinho rmarinho added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Feb 18, 2026
@kubaflo kubaflo added s/agent-fix-lose Author adopted the agent's fix and it turned out to be bad s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-win AI found a better alternative fix than the PR s/agent-fix-lose Author adopted the agent's fix and it turned out to be bad labels Feb 20, 2026
@KarthikRajaKalaimani
Copy link
Contributor Author

🤖 AI Summary

📊 Expand Full Review
🔍 Pre-Flight — Context & Validation
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d
Issue: #33304 - [Android] TitleView defined in Shell is lost when changing tabs PR: #33469 - Fixed Shell TitleView disappears when switching between tabs on Android Author: KarthikRajaKalaimani (Syncfusion partner) Platforms Affected: Android only Regression: Yes - regressed in MAUI 9.0.30 (worked in 9.0.22)

Issue Summary

On Android, Shell.TitleView displays correctly on first tab but disappears when switching to the second tab, then reappears on the third tab. Regression from MAUI 9.0.30.

Root Cause (from PR): When switching tabs, fragments are reused via hide/show. When a fragment becomes visible again via OnHiddenChanged, the TitleView handler update isn't automatically triggered.

Files Changed

  • Fix: src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs (+17, -4)
  • API: src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt (+1)
  • Test HostApp: src/Controls/tests/TestCases.HostApp/Issues/Issue33304.cs (+97)
  • Test NUnit: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33304.cs (+27)

PR Discussion Summary

All addressed Addressed in commit "Set _shellToolbar to null on Destroy method"

  • PureWeen review status: CHANGES_REQUESTED (still pending re-review after fixes were applied)
  • Prior agent review: All 4 phases completed on an earlier commit (7cb9cee) - APPROVE recommended

Fix Candidates

Source Approach Test Result Files Changed Notes

1 try-fix (prior) Post delayed UpdateTitleView() in ShellToolbarTracker.OnShellNavigated() when FAIL ShellToolbarTracker.cs Navigation event fires before fragment visibility change ShellSectionChanged
PR PR #33469 Override OnHiddenChanged to update TitleView when fragment becomes PENDING (Gate) ShellSectionRenderer.cs (+17), PublicAPI.Unshipped.txt (+1) Original PR, all feedback addressed visible
🚦 Gate — Test Verification
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d
Result: ✅ PASSED Platform: android Mode: Full Verification (RequireFullVerification: true)

  • Tests FAIL without fix ✅
  • Tests PASS with fix ✅

Test: Issue33304Test Fix Files Verified:

  • src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs
  • src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt

🔧 Fix — Analysis & Comparison
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d

Fix Candidates

Source Approach Test Result Files Changed Notes

1 try-fix (claude-sonnet-4.5) Add IShellObservableFragment.OnFragmentShown() interface, call from ShellItemRendererBase after CommitAllowingStateLossEx() ✅ PASS 5 files (+interface, +impl, +base call) More complex: adds public API to interface affecting all implementors
2 try-fix (claude-opus-4.6) Subscribe to ShellSection.Appearing event in ShellSectionRenderer ✅ PASS 1 file Simpler event subscription but cross-platform event for Android-specific issue
3 try-fix (gpt-5.2) Use Detach/Attach instead of Hide/Show for ShellSectionChanged in ShellItemRendererBase ✅ PASS 1 file Changes fragment strategy - higher regression risk for other Shell scenarios
4 try-fix (gpt-5.2-codex) Add RefreshToolbarForSection() called from ShellItemRendererBase, resets _toolbarTracker.Page null→current ✅ PASS 2 files Indirect fix through tracker page reset
5 try-fix (gemini-3-pro-preview) Override OnHiddenChanged + reset _toolbarTracker.Page (null→current) instead of calling UpdateValue directly ✅ PASS 2 files Variant of PR approach, less direct
6 try-fix (claude-opus-4.6 R2) Remove guard in ShellToolbarTracker.UpdateTitleView() - root cause investigation ❌ FAIL 1 file Guards are necessary; race condition theory was wrong
PR PR #33469 Override OnHiddenChanged in ShellSectionRenderer, call _shellToolbar.Handler.UpdateValue(nameof(Toolbar.TitleView)) ✅ PASS (Gate) ShellSectionRenderer.cs (+17/-4), PublicAPI.Unshipped.txt (+1) Original PR - minimal, targeted, correct lifecycle

Cross-Pollination Summary

Round Model Response
2 claude-sonnet-4.5 NEW IDEA: Native toolbar API
2 claude-opus-4.6 NEW IDEA: Remove guard in ShellToolbarTracker (→ ran as Attempt 6, ❌ FAIL)
2 gpt-5.2 NEW IDEA: FragmentLifecycleCallbacks/OnFragmentResumed
2 gpt-5.2-codex NEW IDEA: Override OnResume/OnStart (variant of lifecycle approach)
2 gemini-3-pro-preview NEW IDEA: Native RequestLayout/Invalidate
3 claude-sonnet-4.5 ⚠️ Rate limit error
3 claude-opus-4.6 N/A (skipped - rate limits)
3 gpt-5.2 NEW IDEA: IOnAttachStateChangeListener / _toolbar.Post()
3 gpt-5.2-codex NEW IDEA: Conditional reparent in ShellToolbarTracker.UpdateTitleView
3 gemini-3-pro-preview ⚠️ Rate limit error
Exhausted: Yes (rate limits prevented full Round 3 cross-pollination; all substantively different ideas explored and most either pass or were tested)

Selected Fix: PR's fix - It is minimal (only ShellSectionRenderer.cs + public API file), uses the correct Android fragment lifecycle hook (OnHiddenChanged), directly updates the exact property that's broken (TitleView), has proper null checks, uses nameof() for type safety, and has already addressed all reviewer feedback. All passing alternatives are either more complex, carry higher regression risk (Attempt 3: Detach/Attach), or use indirect approaches. The PR's approach is the cleanest direct fix.

📋 Report — Final Recommendation
📝 Review SessionSet _shellToolbar to null on Destroy method · 9eeed4d

✅ Final Recommendation: APPROVE

Summary

PR #33469 fixes a regression (introduced in MAUI 9.0.30) where Shell.TitleView disappears when switching between tabs on Android. The fix is minimal, well-targeted, and all reviewer feedback has been addressed.

Root Cause

When switching Shell tabs on Android, fragments are reused via HideEx()/ShowEx() calls in ShellItemRendererBase.HandleFragmentUpdate (lines 235-242). When a fragment becomes visible again, OnHiddenChanged(false) fires, but the Toolbar.TitleView handler update was never triggered — leaving the TitleView invisible. This is an Android-specific issue tied to fragment lifecycle.

Fix Quality

The PR overrides OnHiddenChanged in ShellSectionRenderer to explicitly update the TitleView handler when the fragment becomes visible:

public override void OnHiddenChanged(bool hidden)
{
    base.OnHiddenChanged(hidden);
    if (!hidden && _shellToolbar?.Handler != null)
    {
        _shellToolbar.Handler.UpdateValue(nameof(Toolbar.TitleView));
    }
}

Why this is the optimal fix:

  • Minimal footprint: 11 lines of logic in 1 Android-specific file
  • Correct lifecycle timing: OnHiddenChanged fires at the exact moment fragment visibility changes
  • Directly updates the broken property (TitleView) with proper null safety and nameof() type safety
  • 5 alternative approaches (try-fix) were explored — all passing but with higher complexity or risk
  • 1 alternative (removing guard in ShellToolbarTracker) confirmed ❌ — guards are necessary

Try-Fix Summary

6 alternatives explored:

  • ✅ Interface method on IShellObservableFragment (more complex, adds public API)
  • ✅ ShellSection.Appearing event subscription (cross-platform event for Android-specific issue)
  • ✅ Detach/Attach instead of Hide/Show (higher regression risk)
  • ✅ RefreshToolbarForSection() via page null→current (more indirect)
  • ✅ OnHiddenChanged with tracker page reset (variant of PR's approach)
  • ❌ Remove guard in ShellToolbarTracker.UpdateTitleView() (guards are necessary)

Selected Fix: PR's fix — simplest, most direct, lowest risk

PR Metadata Review

Title: Minor update recommended

  • Current: Fixed Shell TitleView disappears when switching between tabs on Android (trailing space)
  • Suggested: [Android] Shell: Fix TitleView disappearing when switching between tabs

Description: Good — has NOTE block, root cause, fix description, tested platforms, issue link. Missing "What NOT to Do" section for future agents (guard removal approach doesn't work).

Gate Result

✅ PASSED on Android:

  • Tests FAIL without fix (bug reproduced)
  • Tests PASS with fix

Minor Suggestions (Non-blocking)

  1. Fix trailing space in title, add [Android] prefix
  2. Add "What NOT to Do" to description: Don't remove GetCurrentShellPage() == Page guard in ShellToolbarTracker — guards are necessary
  3. Consider testing Settings tab in test (matches original 3-tab repro) — current test is sufficient

📋 Expand PR Finalization Review

I have renamed the test method as suggested, changing it from Issue33304Test to TitleViewPersistsAfterSwitchingTabs.

I also verified the other Shell and page toolbar properties. The issue does not occur with those properties, as they are independent of Shell.TitleView. Therefore, they do not need to be updated in the OnHiddenChanged method.

Regarding the missing AutomationId for the Settings tab label, it is not required to set an AutomationId for that tab.

@kubaflo
Copy link
Contributor

kubaflo commented Mar 18, 2026

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@github-actions
Copy link
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 -- 33469

Or

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

@KarthikRajaKalaimani
Copy link
Contributor Author

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

I have rebased the branch and resolved the conflicts

@kubaflo kubaflo added the s/agent-suggestions-implemented Maintainer applies when PR author adopts agent's recommendation label Mar 18, 2026
@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@kubaflo kubaflo changed the base branch from main to inflight/current March 19, 2026 13:37
kubaflo

This comment was marked as resolved.

@kubaflo kubaflo merged commit 8a3582a into dotnet:inflight/current Mar 19, 2026
2 of 11 checks passed
PureWeen pushed a commit that referenced this pull request Mar 24, 2026
…id (#33469)

<!-- 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!

### Issue Details:

Shell TitleView disappears when switching between tabs on Android
(regression from MAUI 9.0.30).
        
### Root Cause:

When switching tabs, we reuses fragments by hiding/showing them if the
ShellNavigationSource is ShellSectionChanged in ShellItemRendererBase
class(line number 235 to 242). When a fragment becomes visible again,
the TitleView handler update isn't automatically triggered, leaving the
TitleView invisible.

### Description of Change:

Updated TitleView of the shellToobar when fragment becomes visible after
being hidden, ensuring TitleView appears when switching back to a tab.

**Tested the behavior in the following platforms.**

- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #33304  

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/ba231765-87bd-4de1-aa4f-86a0bb8de6c2"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/621e490d-ab66-4c8a-9d77-43dbd32efd93"
Width="300" Height="600"> |

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) s/agent-suggestions-implemented Maintainer applies when PR author adopts agent's recommendation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] TitleView defined in Shell is lost when changing tabs

9 participants