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

SelectView should work properly with optionValuePath and selection #9468

Merged
merged 1 commit into from
Dec 21, 2014

Conversation

chrmod
Copy link
Contributor

@chrmod chrmod commented Nov 2, 2014

SelectView was not working property when optionValuePath and selection properties were set.
selection and value properties did not update, also selected attribute was not set on option tag.

Typical use case in which SelectView content was bound to ember-data records array and selection was bound to some ember-data object fail to set Select into proper state. Example: http://emberjs.jsbin.com/zemomorunu/1/

This PR aims to improve SelectView so its content can be bound to array of any Ember objects.

TODO:

  • support for multiple=true

@chrmod chrmod changed the title SelectView should work properly with optionValuePath SelectView should work properly with optionValuePath and selection Nov 2, 2014
@chrmod
Copy link
Contributor Author

chrmod commented Nov 2, 2014

Would like to hear some opinions on this one. Especially if support for multiple selection should be a part of this PR or another one.

@wagenet
Copy link
Member

wagenet commented Nov 2, 2014

@chrmod Unfortunately, I've got a bit of bad news for you. Right now we're planning to deprecate Ember.Select and point people towards a new (yet to be added) component version. I'm not sure that we want to merge any changes to Ember.Select at this point. That said, I'll leave this open until we have an official discussion of the future of Ember.Select which will likely take place tomorrow.

@chrmod
Copy link
Contributor Author

chrmod commented Nov 2, 2014

Don't get me wrong, but will not cry after Ember.Select. It is a piece of the framework that gives many people a lot of problems. This PR was created by necessity, as it fixes critical use cases in apps we build.

Looking forward for info of your official discussion.

@ahacking
Copy link

ahacking commented Nov 2, 2014

I'm all for the bright blue sky future but fixing what is there currently should take priority over an as yet unknown future promised land. If there is no viable alternative right this minute then this fix should be merged asap.

For many users the simple alternative is to use another framework where something as basic as a select box actually works.

I want select to not be so broken today and when its replacement lands then great, we can all migrate to that.

Please dont hold out on this PR its not taking the framework in an undsirable direction, or increasing api surface area, its just repairing what's already there.

IMO Ember needs to provide solutions today, and whilst planning for the future is a good thing, if Ember can't do the basics now who cares about all the advanced stuff or future advanced stuff.

@wagenet
Copy link
Member

wagenet commented Nov 2, 2014

See also #5259

@mmun
Copy link
Member

mmun commented Nov 4, 2014

Hi @ahacking I'd like to chat with you sometime if you're available. Please contact me at im.mmun@gmail.com or mmun on #emberjs.

return get(this, labelPath);
}).property(labelPath));
var labelPath = getWithDefault(this, 'parentView.optionLabelPath', 'content');
defineProperty(this, 'label', computed.alias(labelPath));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you import alias directly here (instead of pulling it off of computed)?

@rwjblue
Copy link
Member

rwjblue commented Nov 4, 2014

I agree in general with @ahacking: we should fix the bugs that we can with todays Ember.Select.

@chrmod - I left a few small comments, but overall this looks good.

@chrmod
Copy link
Contributor Author

chrmod commented Dec 21, 2014

@rwjblue code is now updated to current master and your suggestion are applied. Please let me know what you think.

}
});
}.bind(this));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function.prototype.bind is not available in ES3 browsers (which we must support). Please refactor to use a closure scoped variable (like var viewContext = this).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what caused the Travis build to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing that, sorry

collection: Ember.A([{name: 'Wes', value: 'w'}, {name: 'Gordon', value: 'g'}]),
val: 'g',
selectView: SelectView,
template: Ember.Handlebars.compile(templateString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to just compile (instead of Ember.Handlebars.compile -- which is a compat mode alias for the HTMLBars compiler).

rwjblue added a commit that referenced this pull request Dec 21, 2014
SelectView should work properly with optionValuePath and selection
@rwjblue rwjblue merged commit 77c0cd3 into emberjs:master Dec 21, 2014
@rwjblue
Copy link
Member

rwjblue commented Dec 21, 2014

@chrmod - Thank you!

@chrmod chrmod deleted the select-value-path-fixes branch December 21, 2014 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants