[Shell] fix queryParam navigation (#4843)
authorStephane Delcroix <stephane@delcroix.org>
Fri, 21 Dec 2018 15:27:13 +0000 (16:27 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Dec 2018 15:27:13 +0000 (16:27 +0100)
when navigating to pages, not shell-section, handle the queryParams

- fixes #4837

Xamarin.Forms.Core/Shell/Shell.cs
Xamarin.Forms.Core/Shell/ShellContent.cs

index 3a58b76..aa3946b 100644 (file)
@@ -409,11 +409,7 @@ namespace Xamarin.Forms
                        }
 
                        if (!(element is BaseShellItem baseShellItem))
-                       {
                                baseShellItem = element?.Parent as BaseShellItem;
-                               if(baseShellItem == null)
-                                       return;
-                       }
 
                        //filter the query to only apply the keys with matching prefix
                        var filteredQuery = new Dictionary<string, string>(query.Count);
@@ -426,7 +422,10 @@ namespace Xamarin.Forms
                                filteredQuery.Add(key, q.Value);
                        }
 
-                       baseShellItem.ApplyQueryAttributes(filteredQuery);
+                       if (baseShellItem != null)
+                               baseShellItem.ApplyQueryAttributes(filteredQuery);
+                       else if (isLastItem)
+                               ShellContent.ApplyQueryAttributes(element, query);
                }
 
                ShellNavigationState GetNavigationState(ShellItem shellItem, ShellSection shellSection, ShellContent shellContent, IReadOnlyList<Page> sectionStack)
index 9c4e7d9..524d6e8 100644 (file)
@@ -168,7 +168,7 @@ namespace Xamarin.Forms
                        ApplyQueryAttributes(Content as Page, query);
                }
 
-               static void ApplyQueryAttributes(object content, IDictionary<string, string> query)
+               internal static void ApplyQueryAttributes(object content, IDictionary<string, string> query)
                {
                        if (content is IQueryAttributable attributable)
                                attributable.ApplyQueryAttributes(query);