Repository navigation
Fix Shell Navigating event not firing on ShellContent change #34351
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
Merged
kubaflo
merged 12 commits into
dotnet:inflight/current
from
jpd21122012:fix/34318-ShellNavigating-NotTriggered-Windows
Jun 27, 2026
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eff4297
Fix Shell Navigating event not firing on ShellContent change
jpd21122012 2caeb0b
Add UI test for Shell Navigating on ShellContent change
jpd21122012 091b1c5
Fix missing using statements
jpd21122012 fc4e85f
Fix Shell.Navigating not firing on ShellContent change + add test cov…
jpd21122012 b7651de
Fix Shell Navigating event timing and navigation state consistency
jpd21122012 d5dd556
Fix Issue34318 UI test by removing duplicate AutomationId usage
jpd21122012 ce81732
Fix Shell Navigating double-fire on ShellContent change
jpd21122012 b2efae8
Add regression test to ensure Navigating fires exactly once on ShellC…
jpd21122012 344cde4
Avoid duplicate Shell.Navigating notifications on ShellContent changes
jpd21122012 9f536ac
Remove unused Shell parameter from Issue34318 test
jpd21122012 f9586d0
Use OnCurrentItemChanged for ShellContent Navigating notification
jpd21122012 9bcf38f
Avoid duplicate ShellContent Navigating from handler-originated changes
jpd21122012 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.ApplicationModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 34318, "Shell Navigating event should fire on ShellContent change", PlatformAffected.All)] | ||
| public class Issue34318 : Shell | ||
| { | ||
| public Issue34318() | ||
| { | ||
| // When Shell.Navigating fires, broadcast a message the page test can observe | ||
| Navigating += (s, e) => MessagingCenter.Send(this, "NavigatingFired"); | ||
|
|
||
|
jpd21122012 marked this conversation as resolved.
Resolved
|
||
| var section = new ShellSection(); | ||
|
|
||
|
jpd21122012 marked this conversation as resolved.
Resolved
|
||
| var contentA = new ShellContent | ||
| { | ||
| Content = new Issue34318_PageA() | ||
| }; | ||
|
|
||
| var contentB = new ShellContent | ||
| { | ||
| Content = new ContentPage { Title = "PageB", Content = new Label { Text = "Page B", AutomationId = "PageBLabel" } } | ||
| }; | ||
|
|
||
| section.Items.Add(contentA); | ||
| section.Items.Add(contentB); | ||
|
|
||
| var item = new ShellItem(); | ||
| item.Items.Add(section); | ||
|
|
||
| Items.Add(item); | ||
| } | ||
|
|
||
| public class Issue34318_PageA : ContentPage | ||
| { | ||
| Label resultLabel; | ||
|
|
||
| public Issue34318_PageA() | ||
| { | ||
| Title = "PageA"; | ||
|
jpd21122012 marked this conversation as resolved.
Resolved
|
||
| resultLabel = new Label { Text = "Waiting", AutomationId = "ResultLabel" }; | ||
|
|
||
| var button = new Button { Text = "Change Content", AutomationId = "ChangeContentButton" }; | ||
| button.Clicked += (s, e) => | ||
| { | ||
| if (Parent is ShellSection section && section.Items.Count > 1) | ||
| { | ||
| section.CurrentItem = section.Items[1]; | ||
|
jpd21122012 marked this conversation as resolved.
Resolved
|
||
| } | ||
| }; | ||
|
|
||
| // Update the label when the shell raises Navigating (message sent from Shell) | ||
| MessagingCenter.Subscribe<Shell>(this, "NavigatingFired", (sender) => | ||
| { | ||
| MainThread.BeginInvokeOnMainThread(() => | ||
| { | ||
| resultLabel.Text = "Navigating"; | ||
| }); | ||
| }); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = { button, resultLabel } | ||
| }; | ||
| } | ||
| } | ||
| } | ||
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34318.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue34318 : _IssuesUITest | ||
| { | ||
| public Issue34318(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "Shell Navigating event should fire on ShellContent change"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shell)] | ||
| public void NavigatingFiresWhenShellContentChanges() | ||
| { | ||
| // Wait for the page and button | ||
| App.WaitForElement("ChangeContentButton"); | ||
|
|
||
| // Tap the button to change the current ShellContent | ||
| App.Tap("ChangeContentButton"); | ||
|
|
||
| // Wait for the label to update via the Navigating message | ||
| App.WaitForElement("ResultLabel"); | ||
|
|
||
| App.WaitForElement("Navigating"); | ||
|
|
||
| var text = App.FindElement("ResultLabel").GetText(); | ||
|
|
||
| Assert.That(text, Is.EqualTo("Navigating")); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.