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

[BUGFIX BETA] Fix initial selection for select with optgroup #11161

Merged
merged 1 commit into from
May 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ember-htmlbars/lib/templates/select.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#if view.prompt}}<option value="">{{view.prompt}}</option>{{/if}}{{#if view.optionGroupPath}}{{#each view.groupedContent as |group|}}{{view view.groupView content=group.content label=group.label selection=view.selection multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath optionView=view.optionView}}{{/each}}{{else}}{{#each view.content as |item|}}{{view view.optionView content=item selection=view.selection parentValue=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath}}{{/each}}{{/if}}
{{#if view.prompt}}<option value="">{{view.prompt}}</option>{{/if}}{{#if view.optionGroupPath}}{{#each view.groupedContent as |group|}}{{view view.groupView content=group.content label=group.label selection=view.selection value=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath optionView=view.optionView}}{{/each}}{{else}}{{#each view.content as |item|}}{{view view.optionView content=item selection=view.selection parentValue=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath}}{{/each}}{{/if}}
19 changes: 19 additions & 0 deletions packages/ember-views/tests/views/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,25 @@ QUnit.test("select with group doesn't break options", function() {
deepEqual(select.get('selection'), content.get('firstObject'));
});

QUnit.test("select with group works for initial value", function() {
var content = Ember.A([
{ id: 1, firstName: 'Yehuda', organization: 'Tilde' },
{ id: 2, firstName: 'Tom', organization: 'Tilde' },
{ id: 3, firstName: 'Keith', organization: 'Envato' }
]);

run(function() {
select.set('content', content);
select.set('optionGroupPath', 'organization');
select.set('optionValuePath', 'content.id');
select.set('value', 2);
});

append();

equal(select.$().val(), 2, "Initial value is set properly");
});

QUnit.test("select with group observes its content", function() {
var wycats = { firstName: 'Yehuda', organization: 'Tilde' };
var content = Ember.A([
Expand Down