Fixed existing selections not being respected with array data
This fixes an edge case that occurred pretty much whenever anyone would use array data with existing selections along with a placeholder. This caused the existing selections to be discarded, because the `selected` property was not being transferred over to the new option. This was based the new data was being preferred over the data that could be inferred from the option, and the new data typically did not include the selected state. As a result, the option was assumed to not be selected. This was not cause by existing tests because all of the existing tests only covered cases where the selected option was the first option, and that was not affected by this bug.
This commit is contained in:
parent
d1ed0a513a
commit
f3b9693ad9
2
src/js/select2/data/array.js
vendored
2
src/js/select2/data/array.js
vendored
@ -52,7 +52,7 @@ define([
|
||||
var $existingOption = $existing.filter(onlyItem(item));
|
||||
|
||||
var existingData = this.item($existingOption);
|
||||
var newData = $.extend(true, {}, existingData, item);
|
||||
var newData = $.extend(true, {}, item, existingData);
|
||||
|
||||
var $newOption = this.option(newData);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user