-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix intermediate pages not receiving query parameters in multi-page Shell navigation #35432
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
Changes from all commits
b7febe8
dcb7947
95e0ab7
d29c6b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,14 +221,12 @@ public void HandleNavigated(ShellNavigatedEventArgs args) | |
| _shell.PropertyChanged += WaitForWindowToSet; | ||
| var shellContent = _shell?.CurrentItem?.CurrentItem?.CurrentItem; | ||
|
|
||
| if (shellContent != null) | ||
| shellContent.ChildAdded += WaitForWindowToSet; | ||
| shellContent?.ChildAdded += WaitForWindowToSet; | ||
|
|
||
| _waitingForWindow = new ActionDisposable(() => | ||
| { | ||
| _shell.PropertyChanged -= WaitForWindowToSet; | ||
| if (shellContent != null) | ||
| shellContent.ChildAdded -= WaitForWindowToSet; | ||
| shellContent?.ChildAdded -= WaitForWindowToSet; | ||
| }); | ||
|
|
||
| void WaitForWindowToSet(object sender, EventArgs e) | ||
|
|
@@ -320,7 +318,7 @@ public static void ApplyQueryAttributes(Element element, ShellRouteParameters qu | |
| var mergedData = MergeData(element, filteredQuery, isPopping); | ||
|
|
||
| //if we are pop or navigating back, we need to apply the query attributes to the ShellContent | ||
| if (isPopping && mergedData.Count > 0 ) | ||
| if (isPopping && mergedData.Count > 0) | ||
| { | ||
| element.SetValue(ShellContent.QueryAttributesProperty, mergedData); | ||
| } | ||
|
|
@@ -341,6 +339,21 @@ public static void ApplyQueryAttributes(Element element, ShellRouteParameters qu | |
| element.SetValue(ShellContent.QueryAttributesProperty, mergedData); | ||
| } | ||
| } | ||
| else if (element is Page) | ||
| { | ||
| // Intermediate page (not the last item, not wrapped in ShellContent). | ||
| // Apply prefix-filtered query parameters directly via the attached property, | ||
| // which triggers OnQueryAttributesPropertyChanged to handle IQueryAttributable, | ||
| // BindingContext propagation, and [QueryProperty] attributes. | ||
| if (filteredQuery.Count == 0 && !element.IsSet(ShellContent.QueryAttributesProperty)) | ||
| return; | ||
|
|
||
| var mergedData = MergeData(element, filteredQuery, isPopping); | ||
| if (mergedData.Count > 0 || !isPopping) | ||
| { | ||
| element.SetValue(ShellContent.QueryAttributesProperty, mergedData); | ||
|
Comment on lines
+351
to
+354
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — but this is a pre-existing issue in the Fixing this would require changing the shared constructor, which would also affect the ShellContent path. I think that warrants a separate issue/PR rather than mixing it into this bug fix. |
||
| } | ||
| } | ||
|
|
||
| ShellRouteParameters MergeData(Element shellElement, ShellRouteParameters data, bool isPopping) | ||
| { | ||
|
|
||
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.
Fixed in 95e0ab7. Added the ShellContent-style guard:
This skips empty queries on fresh intermediate pages. For pages that previously had params set (re-navigation), an empty query still propagates to allow clearing.
Added test
IntermediatePageWithNoPrefixedParamsDoesNotReceiveEmptyQueryto verify.