Repository navigation
Conversation
<!-- 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! ### Description of Change `Shell.TitleView` content can bind to the Shell instance, but `Shell.Title` was not updated from the active page title. This meant bindings such as `{Binding Title, Source={x:Reference Shell}}` resolved to `null` even when the current `ContentPage.Title` was set. This change mirrors the effective current page or ShellContent title into `Shell.Title` when Shell does not already have a user-set title. The rendered toolbar title still remains empty while a custom TitleView is active, and explicit Shell titles continue to work for Window title fallback. A core unit test covers the TitleView binding scenario and verifies updates when the current page title changes. ### Issues Fixed Fixes #35761 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 1ee8956)
…tive window/status bar (#36334) <!-- 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 Due to the changes introduced in PR #35800, when using Shell on Windows and macOS (Mac Catalyst), the current page's title (intended for the in-app navigation/title bar) was also being displayed in the native window title bar and status bar. ### Description of Changes <!-- Enter description of the fix in this section --> The SetValueFromRenderer(Shell.TitleProperty, title) call was moved inside the if (TitleView != null) block, so Shell.Title is only updated by the renderer when a TitleView is present. Without a TitleView, Shell.Title is left untouched, preventing the page title from propagating to the native window/status bar. ### 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. --> Fixes #36225 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Mac**<br> <img src="https://github.com/user-attachments/assets/fa030b4b-6199-429e-a74a-ed346e118e79" width="600" height="300"> | **Mac**<br> <img src="https://github.com/user-attachments/assets/491d4a74-6acf-458a-8d45-fe3dce25f22f" width="600" height="300"> | --------- (cherry picked from commit 8123cbb)
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36634Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36634" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Backports the Shell.Title/TitleView behavior fix into release/10.0.1xx-sr9 so Shell.Title can be used reliably for bindings when a TitleView is present, while preventing page titles from leaking into the native window/status bar when no TitleView is set.
Changes:
- Update
ShellToolbar.UpdateTitle()to mirror the current page title intoShell.Titleonly when aTitleViewexists and the user hasn’t setShell.Title. - Add unit tests covering
Shell.Titlebindings inTitleViewscenarios and ensuring page titles don’t propagate to native window title when noTitleViewexists. - Add navigation coverage to ensure the “no propagation without TitleView” invariant holds after pushing pages.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Controls/src/Core/ShellToolbar.cs | Guards renderer-driven Shell.Title updates behind TitleView != null and checks whether the user already set Shell.Title. |
| src/Controls/tests/Core.UnitTests/ShellToolbarTests.cs | Adds tests validating Shell.Title reflects current page title for TitleView bindings and respects user-set Shell.Title bindings. |
| src/Controls/tests/Core.UnitTests/ShellTests.cs | Adds regression tests to ensure page title does not propagate to Shell.Title / native window title when no TitleView is present, including after navigation. |
| Title = String.Empty; | ||
| return; | ||
| } | ||
|
|
||
| Title = title; | ||
| } |
There was a problem hiding this comment.
🔍 AI-generated reply on @kubaflo's behalf.
Thoughtful catch, but I'm keeping this out of scope for this PR. This is a servicing backport that cherry-picks #35800/#36334 exactly as merged to inflight/current (this branch's HEAD is the #36334 commit), so the UpdateTitle body here is byte-for-byte the reviewed/merged source.
The TitleView-removal reset you're describing isn't implemented on any branch: main/net11.0 don't renderer-set Shell.Title from UpdateTitle at all (that mechanism is introduced by #35800/#36334), and neither inflight/current nor this backport resets Shell.Title when TitleView becomes null. So it's a pre-existing edge case, not a regression introduced here.
Per servicing policy I don't want to add new, un-forward-ported behavior directly in an SR backport — it would diverge from the merged source. If the runtime TitleView-removal case is a real concern, the right path is a separate forward fix (happy to open one) that then flows through servicing, keeping this PR a faithful backport.
| contentPage.Title = "Updated Test Title"; | ||
|
|
||
| Assert.Equal("Updated Test Title", testShell.Title); | ||
| Assert.Equal("Updated Test Title", label.Text); | ||
| } |
There was a problem hiding this comment.
🔍 AI-generated reply on @kubaflo's behalf.
Same reasoning as the ShellToolbar.cs thread: this is a faithful backport of #35800/#36334, and resetting Shell.Title on TitleView removal isn't behavior this PR implements (nor main/net11.0/inflight/current), so I'm not adding a test for an unhandled transition here. If we forward-fix the removal case, its regression test should land with that fix — keeping the backported tests aligned with the merged source.
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!
Backports #35800 and #36334 to
release/10.0.1xx-sr9.Why both together
Shell.Titlebinding when aTitleViewis present. It was milestoned .NET 10 SR9 and merged to the SR9 servicing branch (inflight/current), but it was never picked into the stabilizedrelease/10.0.1xx-sr9branch, so the stable SR9 release is currently missing this fix.SetValueFromRenderer(Shell.TitleProperty, …)call so it only runs when aTitleViewexists, which fixes the leak.ShellToolbar.csis byte-identical to the corrected state oninflight/current.Changes
src/Controls/src/Core/ShellToolbar.cs— guarded title propagation (cherry-picks of Fix Shell.Title binding in TitleView #35800 + [inflight/current] [Windows/Mac] Fix Shell page title leaking into native window/status bar #36334)src/Controls/tests/Core.UnitTests/ShellToolbarTests.cs— new tests (Fix Shell.Title binding in TitleView #35800)src/Controls/tests/Core.UnitTests/ShellTests.cs— new leak-guard tests ([inflight/current] [Windows/Mac] Fix Shell page title leaking into native window/status bar #36334)Cherry-picked from:
1ee8956882d(Fix Shell.Title binding in TitleView #35800)8123cbb9d08([inflight/current] [Windows/Mac] Fix Shell page title leaking into native window/status bar #36334)Fixes #36225 for SR9.