-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ApplyQueryAttributes gets called with empty Dictionary on back #33415
Description
Description
Trusting Microsoft's doc:
- Calling
query.Clear()(in case ofDictionary<string, object>) - Using a
ShellNavigationQueryParametersas 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, doquery.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
ApplyQueryAttributesmethod get called with an emptyDictionary
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.