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 type=checkbox isn't a component #5433

Closed
ctataryn opened this issue Aug 19, 2014 · 33 comments
Closed

Input type=checkbox isn't a component #5433

ctataryn opened this issue Aug 19, 2014 · 33 comments

Comments

@ctataryn
Copy link

Although this issue was closed (#3935), I think it would be worthwhile to support {{input type="checkbox" action="someaction"}}.

In developing my app I could not actually wire up an action to a checkbox in this manner.

Although according to the referenced issue this would be a "breaking change", I believe it would add symmetry (and reduce confusion)

cc @stefanpenner (this even confused the mighty one)

@knownasilya
Copy link
Contributor

👍 Totally flaked out for a bit and thought that you were saying that you can't do {{input type='checkbox'}}.. but you're referring to the fact that it's not a component internally and doesn't support actions.

This issue might also be slightly related to emberjs/rfcs#2

@rwjblue
Copy link
Member

rwjblue commented Aug 20, 2014

Making your own checkbox component is extremely straightforward:

http://emberjs.jsbin.com/rwjblue/58/edit

For the reasons stated in #3935 (comment) we cannot change Ember.Checkbox to be a subclass of Ember.Component.

@rwjblue rwjblue closed this as completed Aug 20, 2014
@stefanpenner stefanpenner reopened this Aug 20, 2014
@stefanpenner
Copy link
Member

@rwjblue {{input type="checkbox"}} should be a component, Ember.CheckBox should remain the same. This addresses the concern from #3935

{{input}} and {{input type="checkbox"}} behavior totally differently is a mind-fuck

@rwjblue
Copy link
Member

rwjblue commented Aug 20, 2014

{{input type="checkbox"}} currently just uses Ember.CheckBox (see here).

I am absolutely sorry that this is mentally complicated, but we cannot change either {{input type="checkbox"}} or Ember.Checkbox to a Component without breaking backwards compatibility. I attempted to fix exactly this disconnect in #3935, but that was correctly declined.

@stefanpenner
Copy link
Member

@rwjblue we should consider introducing Ember.CheckBoxComponent and deprecating Ember.CheckBox (to be removed in 2.0).

{{input... }} then uses Ember.CheckBoxComponent and leaves the Ember.CheckBox alone.

The fact that the component syntax {{input gives you a component for type="text" but not type="checkbox" is an unfortunately a bug.

This will affect people who use reopen Ember.CheckBox and use {{input type="checkbox"}} but they can very easily switch to {{view Ember.CheckBox}}

We might have to be careful how this is released, but it will prevent some early gray hair.

@rwjblue
Copy link
Member

rwjblue commented Aug 20, 2014

Slight correction {{input}} is helper syntax (as components require a dash). Also, we have deprecated {{view AccessSomeGlobal}}.

@asteinlein
Copy link

As a newcomer to Ember, a huge +1 from me (and everyone in my company) on cleaning this up for Ember 2.0 or whenever. We wasted a lot of time with this until we found this thread.

@stefanpenner
Copy link
Member

@asteinlein I have also wasted an embarrassing amount of time on this one.

@rwjblue you are correct via globals, but they can easily import / export Ember.CheckBox.extend in there own app and use {{view 'check-box'}}

I believe we should and can change {{input type="checkbox"}} to be a component but leave Ember.CheckBox as a view.

@rwjblue
Copy link
Member

rwjblue commented Oct 1, 2014

@stefanpenner - I respectfully disagree. We cannot change {{input type="checkbox"}} to use a component within a 1.X release without breaking our SemVer contract.

But I do completely sympathize and want this changed to use a component in 2.0, if you recall I submitted a PR that did just that but the PR was declined because of SemVer impact.

@knownasilya
Copy link
Contributor

@rwjblue what about making a ember-cli addon version, for those suffering?

@stefanpenner
Copy link
Member

@rwjblue what breaks?

The past complaints where people who subclasses TextField for there own TextFields not the `{{input`` helper variant.

@wagenet
Copy link
Member

wagenet commented Nov 1, 2014

@rwjblue ping.

@petrvolny
Copy link
Contributor

Any news on this one?

@Restuta
Copy link

Restuta commented Jan 29, 2015

Yeah, just got hit by that..

@stefanpenner
Copy link
Member

  • see what glimmer changed here
  • we MUST fix this for 2.0

@ef4
Copy link
Contributor

ef4 commented Mar 20, 2015

I reviewed this on the glimmer branch, it is not yet fixed. Checkbox still inherits View and not Component, despite being registered in the container under the name component:-checkbox.

@stefanpenner
Copy link
Member

cc @tomdale @wycats

@ronco
Copy link
Contributor

ronco commented Apr 15, 2015

👍 would love to see this behavior consistent in 2.0.

@SirZach
Copy link

SirZach commented Apr 29, 2015

just want to comment on @rwjblue x-checkbox component, you need to add 'checked' to the attributeBindings array if you want to be able to programmatically set the checked value of the element. You'll also need to pass it in: {{x-checkbox checked=propertyBoundToCheckedState}}.

@KTKate
Copy link

KTKate commented May 10, 2015

Wasted so much time on this.

At least put a warning, in bold, in the docs. It's a little misleading considering the 'actions' usage is explained only a line before 'checkboxes' on the Input Helpers guide page.

@SirZach
Copy link

SirZach commented May 10, 2015

@JKGisMe i feel ya, don't give up on ember due to this problem. i fully believe ember core team is going to make this a non-issue with ember 2.0!

@KTKate
Copy link

KTKate commented May 10, 2015

Well, I have a working, saving to the backend, checkbox. I used combination of the x-checkbox JSBin here and the explanation at http://www.thesoftwaresimpleton.com/blog/2015/02/12/emberjs-data-down/ The explanation was really helpful.

I don't know when Ember 2.0 will come out but it seems like a slippery slope to delay workable solutions. Especially when the situation is not well documented. It's already hard enough for a noob when the internets are full of the 'old Ember way' and you're trying to implement things in the 'new Ember way'. There is no reason something like this checkbox debacle couldn't have been included on the Ember guides. Checkboxes are a pretty basic element. I guess I find this to be equal part issue with Ember itself and issue with Ember documentation.

@rwjblue
Copy link
Member

rwjblue commented May 10, 2015

I don't know when Ember 2.0 will come out

The recent blog post should provide more detail.

@Restuta
Copy link

Restuta commented May 11, 2015

@JKGisMe this is open source project, so please help to improve documentation or really anything in the code. Community would greatly appreciate that.

@knownasilya
Copy link
Contributor

@rwjblue thanks for that link.

@KTKate
Copy link

KTKate commented May 13, 2015

@Restuta I spent half my Sunday trying to make a checkbox. I don't think Ember wants me touching their code. ;)

Since Ember 2.0 is so close. Let's just pause our work projects and come back after it's here. We can contribute to Ember in the meantime.

@jfelchner
Copy link

I just ran into this and spent an hour on it until I gave up and finally found this. I hope this gets fixed for 2.0.

@rwjblue
Copy link
Member

rwjblue commented Jun 10, 2015

Fixed in #11396

@rwjblue rwjblue closed this as completed Jun 10, 2015
@KTKate
Copy link

KTKate commented Jun 13, 2015

Yay, future generations of ember noobs will not know the struggle. 👍

@gzurbach
Copy link

gzurbach commented Jul 9, 2015

Hey guys, quick question here to clear out some confusion. I was looking at the code change (#11396) to make checkbox extend from view to component and I was wondering what the implications are...

Does this change mean that with the next release of Ember we will be able to write:

{{input type="checkbox" value=isChecked action="foo"}}

If so, when will foo be triggered? On change or on click or... something else?

Related question: are we gonna be able to write something like:

{{input type="checkbox" value=isChecked action="foo" on="click"}}

My issue right now is that I'd like to be notified when the user toggles the checkbox but not when I programmatically change its value. The only way for now to be notified of a change is to set an observer on the checkbox's value. Unfortunately the observer is being triggered both when the user clicks on the checkbox and when I toggle its value programmatically. I was therefore wondering is that change would help me accomplish what I'm trying to do.

@stefanpenner
Copy link
Member

@gzurbach in ember 1.13.3 you can do the following

<input type="checkbox" value={{isChecked}} onclick={{action "foo" value="target.checked"}} />

@gzurbach
Copy link

gzurbach commented Jul 9, 2015

Awesome, I will do that then. Thanks for your quick reply @stefanpenner, as always!

@tcjr
Copy link

tcjr commented Nov 12, 2015

@stefanpenner After an embarrassing amount of debugging, I can verify this should be

checked={{isChecked}}

instead of

value={{isChecked}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests