Fix tag order when selecting existing tags

refs #5773
- overrides ember-cli-selectize's `_addSelection` method to insert objects at the correct index instead of always adding at the end
This commit is contained in:
Kevin Ansfield 2015-09-01 17:34:31 +01:00
parent 2da1a06196
commit 5596fd808b

View File

@ -41,6 +41,24 @@ export default EmberSelectizeComponent.extend({
// We cancel the creation here, so it's up to you to include the created element // We cancel the creation here, so it's up to you to include the created element
// in the content and selection property // in the content and selection property
callback(null); callback(null);
},
_addSelection(obj) {
var _valuePath = this.get('_valuePath'),
val = Ember.get(obj, _valuePath),
caret = this._selectize.caretPos;
// caret position is always 1 more than the desired index as this method
// is called after selectize has inserted the item and the caret has moved
// to the right
caret = caret - 1;
this.get('selection').insertAt(caret, obj);
Ember.run.schedule('actions', this, function () {
this.sendAction('add-item', obj);
this.sendAction('add-value', val);
});
} }
}); });