Skip to content

Commit f4e0089

Browse files
committed
cleaned up loading/cleaning of result list
1 parent 2dc46c4 commit f4e0089

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

select2.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -356,24 +356,19 @@
356356

357357
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
358358

359+
this.updateResults();
360+
this.ensureHighlightVisible();
359361
this.alignDropdown();
360362
this.dropdown.show();
363+
this.focusSearch();
361364
};
362365

363366
AbstractSelect2.prototype.close = function () {
364367
if (!this.opened()) return;
365368

366369
this.dropdown.hide();
367370
this.container.removeClass("select2-dropdown-open");
368-
369-
if (this.select) {
370-
// TODO see if we can always clear here and reset on open
371-
this.search.val(""); // not using clearSearch() because it may set a placeholder
372-
this.updateResults(); // needed since we just set the search text to ""
373-
} else {
374-
this.results.empty();
375-
}
376-
371+
this.results.empty();
377372
this.clearSearch();
378373
};
379374

@@ -610,12 +605,6 @@
610605
width -= getSideBorderPadding(this.container.find(".select2-search"));
611606
width -= getSideBorderPadding(this.search);
612607
this.search.css({width: width});
613-
614-
if (!this.select) this.updateResults();
615-
616-
this.ensureHighlightVisible();
617-
618-
this.focusSearch();
619608
};
620609

621610
SingleSelect2.prototype.close = function () {
@@ -915,7 +904,6 @@
915904
if (this.opened()) return;
916905
this.parent.open.apply(this, arguments);
917906
this.resizeSearch();
918-
this.ensureHighlightVisible();
919907
this.focusSearch();
920908
};
921909

0 commit comments

Comments
 (0)