Description
Trusting Microsoft's doc:
- Calling
query.Clear() (in case of Dictionary<string, object>)
- Using a
ShellNavigationQueryParameters as a navigation params holder
... should avoid ApplyQueryAttributes(query) to be called when we re-navigate to the existing page (for example with a GoToAsync("..") from a page we'd have opened afterwards).
The issue is: it seems it gets called in both cases with an empty Dictionary.
Steps to Reproduce
Shell.Current.GoToAsync(PageA, new Dictionary<string, object> { { "MyKey", "MyValue" } });
- On PageA's ViewModel
ApplyQueryAttributes, do query.Clear();
- From PageA ->
Shell.Current.GoToAsync(PageB);
- From PageB -> Either you can press the back button in the title bar or call
Shell.Current.GoToAsync("..");
- You get back on PageA, and its ViewModel's
ApplyQueryAttributes method get called with an empty Dictionary
Link to public reproduction project repository
No response
Version with bug
10.0.20
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
Returning from the method at the start of ApplyQueryParameters if query is empty basically fixes the issue, but the documentation from Microsoft is driving people wrong.
Also, and as far as I personally think, ApplyQueryParameters(query) should always get called, no matter there are arguments or not, so we could ensure we can initialize the ViewModel from there. Currently, we have to jungle with ApplyQueryParameters and OnAppearing (which gets called earlier so it misses the parameters) depending there are parameters or not, and it's pretty painful.
Relevant log output
Description
Trusting Microsoft's doc:
query.Clear()(in case ofDictionary<string, object>)ShellNavigationQueryParametersas a navigation params holder... should avoid
ApplyQueryAttributes(query)to be called when we re-navigate to the existing page (for example with aGoToAsync("..")from a page we'd have opened afterwards).The issue is: it seems it gets called in both cases with an empty
Dictionary.Steps to Reproduce
Shell.Current.GoToAsync(PageA, new Dictionary<string, object> { { "MyKey", "MyValue" } });ApplyQueryAttributes, doquery.Clear();Shell.Current.GoToAsync(PageB);Shell.Current.GoToAsync("..");ApplyQueryAttributesmethod get called with an emptyDictionaryLink to public reproduction project repository
No response
Version with bug
10.0.20
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
Returning from the method at the start of
ApplyQueryParametersifqueryis empty basically fixes the issue, but the documentation from Microsoft is driving people wrong.Also, and as far as I personally think,
ApplyQueryParameters(query)should always get called, no matter there are arguments or not, so we could ensure we can initialize the ViewModel from there. Currently, we have to jungle withApplyQueryParametersandOnAppearing(which gets called earlier so it misses the parameters) depending there are parameters or not, and it's pretty painful.Relevant log output