Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input helper passed type does not work in Ember 3.1 beta #16256

Closed
RobbieTheWagner opened this issue Feb 17, 2018 · 5 comments
Closed

Input helper passed type does not work in Ember 3.1 beta #16256

RobbieTheWagner opened this issue Feb 17, 2018 · 5 comments
Labels

Comments

@RobbieTheWagner
Copy link
Member

RobbieTheWagner commented Feb 17, 2018

I was working on updating my apps and addons to 3.1 beta and noticed some strange behavior. I have components that wrap the {{input}} helper and only the first one was rendering an input. I created a reproduction here https://github.com/rwwagner90/inputs and I played around with it some. It appears the issue is passing type down as an argument. It chokes on:

{{input type=type}}

I also tested this against https://s3.amazonaws.com/builds.emberjs.com/canary/shas/9300d1b7d3aa70987986b1997ecf02a542ea49be.tgz and there did not seem to be any difference.

@rwjblue
Copy link
Member

rwjblue commented Feb 17, 2018

Awesome, thank you for the reproduction!

@Serabe
Copy link
Member

Serabe commented Feb 23, 2018

Forked repo. Investigating since I did two changes related to input type, one in Ember and one in Glimmer.

Serabe added a commit to Serabe/ember.js that referenced this issue Feb 23, 2018
Serabe added a commit to Serabe/ember.js that referenced this issue Feb 23, 2018
@rwjblue
Copy link
Member

rwjblue commented Feb 24, 2018

Seems very bizarre indeed...

@Serabe
Copy link
Member

Serabe commented Feb 26, 2018

Let me write my findings so far, because this is quite strange.

Background

input is neither a component nor a helper. It is referred as a macro, and the closer explanation is that they work like a low-level helper. In any case, this is only important to understand why the code for input does not look like anything familiar for the users of Ember.

input requires a template compiler plugin that transforms {{input type=boundType}} into {{input (-input-type boundType) type=boundType}}.

-input-type is an internal helpers that basically checks if the given parameters is "checkbox" and returns the name of a component based on that.

Checking the bug

First thing I noticed is that there was no error in the console and the rendering was working past the first breaking input. Looking more deeply, changing the order of the types, would keep the same result: only the first input would be rendered.

Also, the input being inside a component is required. If we are to add three inputs directly into application.hbs, they would just work, which invalidates the theory that the problem is type not being handled. Moreover, if we are to add more {{input}}s after the failing component, these just work!

What is happening?

While checking in the DevTools the execution of the input macro, I saw that params had different length from the first execution, to the rest. The rest are missing the first param, the one added by the compiler plugin.

Summary

  • It is not a problem in the input macro handling type.
  • It is a problem with the params being passed to the input macro.
  • It does not fails if {{input}} is directly in application.hbs.

Serabe added a commit to Serabe/ember.js that referenced this issue Feb 26, 2018
Before this PR, having a component with an `{{input}}` with bound type
would make that input only to work the first time it was rendered. This
was because the first param would be shifter from params, and that would
modify the params of the rest of the instances.

Fixes emberjs#16256
@Serabe Serabe added the Has PR label Feb 26, 2018
Serabe added a commit to Serabe/ember.js that referenced this issue Feb 27, 2018
Before this PR, having a component with an `{{input}}` with bound type
would make that input only to work the first time it was rendered. This
was because the first param would be shifter from params, and that would
modify the params of the rest of the instances.

Fixes emberjs#16256
@RobbieTheWagner
Copy link
Member Author

👏 thanks for the fix!

kategengler pushed a commit that referenced this issue Mar 5, 2018
Before this PR, having a component with an `{{input}}` with bound type
would make that input only to work the first time it was rendered. This
was because the first param would be shifter from params, and that would
modify the params of the rest of the instances.

Fixes #16256

(cherry picked from commit 51f09b5)
Serabe added a commit to Serabe/ember.js that referenced this issue Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants