Query params from link-to destination wiped out if the current URL has a different query param
Hi all,
I'm experiencing an issue where I have a link-to specifying a particular query param with its destination, like so: {{#link-to "foo.bar" (query-params baz=true)}}. This link-to is on route my-route with a different query param (URL has "my-route?creating=true"). When I click that link-to, I am successfully taken to foo.bar, but my query param of baz=true seems to be wiped out.
I can get around this by adding "baz" to the query params on the controller for "my-route" like so: queryParams: ['creating', 'baz'], but this seems like a band-aid fix to a larger problem. And it doesn't entirely make sense because baz is not relevant to "my-route".
My team's project is currently on version 2.18 of Ember. I've looked around for other similar issues posted here but could not find anything. Apologies if there is one that I missed somewhere.
Thanks!
@danielraggs I think that is the expected behavior, that query params are per route/controller - not global to the app (like we would expected in a traditional server rendered html app)
See: https://guides.emberjs.com/release/routing/query-params/#toc_sticky-query-param-values the controller tracks the param value, not the URL.
Perhaps we can document this expectation more clearly.
@pixelhandler : I hit the same issue today and couldn't find documentation either. Came across this thread and created a pull request for documentation update.