-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
Shell.Current.Navigation.PushAsync and Shell.Current.Navigation.PushModalAsync does call IQueryAttributable.ApplyQueryAttributes by default (with empty parameters) and does not allow you to pass in custom parameters.
Shell.Current.GoToAsync does not call IQueryAttributable.ApplyQueryAttributes by default and does allow you to pass in custom parameters.
These should behave in the same way. In my opinion, both should call IQueryAttributable.ApplyQueryAttributes by default and both should allow you to pass in your own route parameters.
If this gets picked up and a reproduction is desired, I will happily put something together.
Steps to Reproduce
Scenario #1
- Create a page with a view model that implements IQueryAttributable. For convenience, make the view model a public property.
- Use Shell navigation to navigate to that page without route parameters (or with an empty dictionary. Both behave the same)
- Observe that ApplyQueryAttributes does not get called
Scenario #2
- Create an instance of the same page
- Use PushAsync to navigate to that same page
- Observe that you do not have the option of passing your own
- Observe that ApplyQueryAttributes does get called
Scenario #3
- Create an instance of the same page
- Find the view model field and call ApplyQueryAttributes yourself. Store the query attributes that came in (in the view model).
- Call PushAsync with the page instance to navigate to that page
- Observe that ApplyQueryAttributes gets called and resets your stored route parameters. And causes other miscellaneous havoc in your view model if you're using it to initialize your view model.
Link to public reproduction project repository
No response
Version with bug
7.0.92
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
iOS 16
Did you find any workaround?
With a bunch of custom code. I have a navigation abstraction so that I can control passing in route parameters. Because Shell.Current.GoToAsync won't call IQueryAttributable.ApplyQueryAttributes, I am passing a dummy route parameter to force it. That's gross, but I didn't see a better way.
I'm also wrapping PushAsync and PushModalAsync so that I can use dependency injection to initialize the page and view mdoel. That should also not be necessary - I should just be able to pass a type (e.g. Shell.Current.PushModalAsync(myRouteParameters, true) and it should get the page from the IoC, but that's a different issue.
Relevant log output
No response