intercom/ember-href-to

Respect parent route query params

Opened this issue · 6 comments

In my app I have a query param at the application level. Most of the time it'll never make it's way into the URL because the default value is not changed. However, when it is, it seems like any {{href-to}} URL's don't know about that, probably because it isn't passed in as (query-params). The issue would be that child routes don't really have direct access to the current value to pass in. Is there a way for this helper to know about those and add them to the URL automatically?

@cibernox Would PR #47 resolve this issue?

Yes, that was the idea, but I have to admit that I hit a dead end with that. The logic around query params was quite messy. I should try to finish it, but I don't think I'll have time in the next days.

@homersimpsons I didn't find a solution for the PR and i forgot about it. I'm not sure if with the new router service almost done in newer versions we should keep pursuing this as it will be an "official" href-to soon.

@cibernox Okay, thank you for your answer :)

It should be possible to achieve this via ember-router-helpers.

{{#with (route-params 'parent.child') as |routeParams|}}
   <a href={{routeParams.url}}
    class={{if routeParams.isActive "active" "inactive"}}
    {{action routeParams.transitionTo}}>Blah</a>
{{/with}}

I didn't test it directly, but I tried it in my own version of those. The core difference is that the transition is not handled via URL handling but by using route params directly.