ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

Query params from link-to destination wiped out if the current URL has a different query param

Open danielraggs opened this issue 7 years ago • 2 comments

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 avatar Aug 06 '18 18:08 danielraggs

@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 avatar Aug 25 '18 00:08 pixelhandler

@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.

LalithaRajanala avatar Oct 17 '18 00:10 LalithaRajanala