Ember.js: [2.15.0] {{link-to}} inside a partial stopped working

Created on 1 Sep 2017  ·  25Comments  ·  Source: emberjs/ember.js

After upgrading to 2.15.0 some of our tests started failing because a {{#link-to}} inside of a partial stopped working.

This is the {{link-to}} in question. When rendering there are no immediate errors but the generated href is just # and the data-test-user-id attribute is not output when testing. Clicking the link outputs this warning:

This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.

Everything else inside of the partial still renders fine, it's just the link-to that fails.

Changing the partial to a component fixed the problem.

Bug Ember 2.15

Most helpful comment

Reproduction in 2.15. Same twiddle working in 2.14.

All 25 comments

I've come across a similar problem in 2.15, it seems that a partial rendered inside a yielded block from a component doesn't receive the yielded parameters from that component.

Example:

// -name.hbs
<p>{{name}}</p>

component.js

export default Component.extend({
  name: "Ivan"
})

template.hbs

{{yield name}}

some-route-template.hbs

{{#my-component as |name|}}
  {{partial "name"}}
{{/my-component}}

In this instance, the {{name}} variable in the partial is undefined.

The same thing happens with an #each iteration. The value from #each isn't passed to the context of the partial.

{{#each visibleContent as |record index|}}
  {{partial rowTemplate}}
{{/each}}

Both record and index are undefined in the partial.

Reproduction in 2.15. Same twiddle working in 2.14.

Interestingly enough, I can still reference a "lost" variable's property by its name, e.g. in the rowTemplate I could do record.id but not (get record "id"). Not sure if that's of any help debugging the issue.

Is this behavior legacy, or is there an alternative approach that should be considered? We've been trying to use components over partials, but for our largish app there are still many instances where this bug is breaking things. At this point, we are blocked from upgrading, and I am surprised this isn't affecting more folks.

No, this isn't legacy behavior per-se, but it is fairly uncommon. You should _totally_ migrate to using components whenever you can (it is massively simpler to reason about), but we should absolutely fix this ASAP.

@rwjblue any pointers where I should start looking to help fix this?

I submitted https://github.com/emberjs/ember.js/issues/15674 with some failing tests cases. It seems the issue isn’t as simple as accessing bound property values within the partial (at least it didn’t seem so with my testing). I believe the underlying issue has to do with the way we generate the references used by things like if, unless, with, and get.

Sadly, I don’t have a smoking gun to point at though. :(

we are also unable to upgrade due to this bug. similar to @thec0keman we have a fairly large ember app which was originally started using EAK, so there's still some lingering legacy functionality that we haven't yet brought to modern ember

we don't have a lot of partials left, but enough that this is a blocker for us until we have the time to migrate / test the remaining partials to components

This one should really get some higher priority, partials are broken since 2.15 and prevent people to upgrade from 2.14 to 2.16.

+1

I'm going to take a look at this next week after EmberFest.

I've extended the twiddle of @Serabe and found out, that if a property with the same name gets defined in the controller, the partials gets the right value. But if a value in a array is undefined the partial still thinks that it has a truthy value.

This a bug in Glimmer. See in the referenced issue.

A new glimmer version with the fix was released. After updating the glimmer version this bug should be fixed. I've opened a pull request for updating the glimmer version.

FYI - The upgrade to Glimmer 0.29 is a large effort (and unlikely to happen before Ember 3.0.0), @chadhietala backported the fix to the 0.25 branch. We need to release that as a patch version and update to that version instead. I’ll try to get these releases done today...

@rwjblue LMK if there is anything that i can help with the release which includes the patched 0.25 branch (as I'm working on upgrading Intercom at the moment). As far as I can tell, it hasn't yet reached ember canary

The same problem also exists if using the with helper:

{{#with someProperty as |youNameIt|}}
  {{partial somePartial}}
{{/with}}

Probably the patch will fix this too, but to be sure I do mention it here!

Hi. Is there a fix released for this issue? As far as i can tell, most of the helpers are somewhat affected when used in a partial. Is there a workaround?

Ember 2.16.1 has been released which should fix the issues with partials. Please let me know if you're still seeing issues

While these issues have been fixed, FYI I just found another issue with partials:

https://github.com/emberjs/ember.js/pull/15797

I'll work on fixing this later today

Are you guys completely sure it's been solved for 2.15? The twiddle from @Serabe (https://github.com/emberjs/ember.js/issues/15621#issuecomment-326823615) still fails on 2.15.3, but works on 2.16.1.

Incidentally, I've noticed that if you modify the partial to write the name, it actually prints the correct value...

image

It is not. Ember 2.15 is not an LTS, so I don't think a fix will be coming.

Confirm.

Oh, ok. I thought the fix being backported to glimmer 0.25 would meant this working on Ember 2.15 too. Guess we'll skip directly to 2.16 then. Thanks!!

Was this page helpful?
0 / 5 - 0 ratings