Revert "Add hideSelectionFromResult function"
This reverts commit 84cf134a4e
.
New problems found in:
https://github.com/ivaynberg/select2/issues/2196
Original issue:
https://github.com/ivaynberg/select2/issues/1538
Pull request:
https://github.com/ivaynberg/select2/pull/2032
This commit is contained in:
parent
d9f54a617c
commit
63f342a12f
24
select2.js
24
select2.js
@ -2278,14 +2278,13 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
// single
|
// single
|
||||||
postprocessResults: function (data, initial, noHighlightUpdate) {
|
postprocessResults: function (data, initial, noHighlightUpdate) {
|
||||||
var selected = 0, selectedElm = null, self = this, showSearchInput = true;
|
var selected = 0, self = this, showSearchInput = true;
|
||||||
|
|
||||||
// find the selected element in the result list
|
// find the selected element in the result list
|
||||||
|
|
||||||
this.findHighlightableChoices().each2(function (i, elm) {
|
this.findHighlightableChoices().each2(function (i, elm) {
|
||||||
if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
|
if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
|
||||||
selected = i;
|
selected = i;
|
||||||
selectedElm = elm;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2293,14 +2292,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
// and highlight it
|
// and highlight it
|
||||||
if (noHighlightUpdate !== false) {
|
if (noHighlightUpdate !== false) {
|
||||||
if (initial === true && selected >= 0) {
|
if (initial === true && selected >= 0) {
|
||||||
// By default, the selected item is displayed inside the result list from a single select
|
this.highlight(selected);
|
||||||
// User can provide an implementation for 'hideSelectionFromResult' and hide it
|
|
||||||
if(selectedElm !== null) {
|
|
||||||
if(this.opts.hideSelectionFromResult(selectedElm))
|
|
||||||
selectedElm.addClass("select2-selected");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.highlight(selected);
|
|
||||||
} else {
|
} else {
|
||||||
this.highlight(0);
|
this.highlight(0);
|
||||||
}
|
}
|
||||||
@ -3029,14 +3021,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
choices.each2(function (i, choice) {
|
choices.each2(function (i, choice) {
|
||||||
var id = self.id(choice.data("select2-data"));
|
var id = self.id(choice.data("select2-data"));
|
||||||
if (indexOf(id, val) >= 0) {
|
if (indexOf(id, val) >= 0) {
|
||||||
// By default, the selected item is hidden from the result list inside a multi select
|
choice.addClass("select2-selected");
|
||||||
// User can provide an implementation for 'hideSelectionFromResult' and allow the same
|
// mark all children of the selected parent as selected
|
||||||
// element to be selected multiple times.
|
choice.find(".select2-result-selectable").addClass("select2-selected");
|
||||||
if(self.opts.hideSelectionFromResult(choice) === undefined || self.opts.hideSelectionFromResult(choice)) {
|
|
||||||
choice.addClass("select2-selected");
|
|
||||||
// mark all children of the selected parent as selected
|
|
||||||
choice.find(".select2-result-selectable").addClass("select2-selected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -3353,7 +3340,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
adaptContainerCssClass: function(c) { return c; },
|
adaptContainerCssClass: function(c) { return c; },
|
||||||
adaptDropdownCssClass: function(c) { return null; },
|
adaptDropdownCssClass: function(c) { return null; },
|
||||||
nextSearchTerm: function(selectedObject, currentSearchTerm) { return undefined; },
|
nextSearchTerm: function(selectedObject, currentSearchTerm) { return undefined; },
|
||||||
hideSelectionFromResult: function(selectedObject) { return undefined; },
|
|
||||||
searchInputPlaceholder: '',
|
searchInputPlaceholder: '',
|
||||||
createSearchChoicePosition: 'top',
|
createSearchChoicePosition: 'top',
|
||||||
shouldFocusInput: function (instance) {
|
shouldFocusInput: function (instance) {
|
||||||
|
Loading…
Reference in New Issue
Block a user