Skip to content

[BUG] Route parameter behavior is not consistent #17517

@mmiller-d8

Description

@mmiller-d8

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

  1. Create a page with a view model that implements IQueryAttributable. For convenience, make the view model a public property.
  2. Use Shell navigation to navigate to that page without route parameters (or with an empty dictionary. Both behave the same)
  3. Observe that ApplyQueryAttributes does not get called

Scenario #2

  1. Create an instance of the same page
  2. Use PushAsync to navigate to that same page
  3. Observe that you do not have the option of passing your own
  4. Observe that ApplyQueryAttributes does get called

Scenario #3

  1. Create an instance of the same page
  2. Find the view model field and call ApplyQueryAttributes yourself. Store the query attributes that came in (in the view model).
  3. Call PushAsync with the page instance to navigate to that page
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions