Merge pull request #5621 from select2/GH-5619
Fix bug where dropdowns pointing upwards were incorrectly positioned
This commit is contained in:
commit
9e4f842fb1
66
src/js/select2/dropdown/attachBody.js
vendored
66
src/js/select2/dropdown/attachBody.js
vendored
@ -16,6 +16,9 @@ define([
|
||||
container.on('open', function () {
|
||||
self._showDropdown();
|
||||
self._attachPositioningHandler(container);
|
||||
|
||||
// Must bind after the results handlers to ensure correct sizing
|
||||
self._bindContainerResultHandlers(container);
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
@ -23,31 +26,6 @@ define([
|
||||
self._detachPositioningHandler(container);
|
||||
});
|
||||
|
||||
container.on('results:all', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('results:append', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('results:message', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('select', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('unselect', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
this.$dropdownContainer.on('mousedown', function (evt) {
|
||||
evt.stopPropagation();
|
||||
});
|
||||
@ -89,6 +67,44 @@ define([
|
||||
this.$dropdownContainer.detach();
|
||||
};
|
||||
|
||||
AttachBody.prototype._bindContainerResultHandlers =
|
||||
function (decorated, container) {
|
||||
|
||||
// These should only be bound once
|
||||
if (this._containerResultsHandlersBound) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
container.on('results:all', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('results:append', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('results:message', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('select', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
container.on('unselect', function () {
|
||||
self._positionDropdown();
|
||||
self._resizeDropdown();
|
||||
});
|
||||
|
||||
this._containerResultsHandlersBound = true;
|
||||
};
|
||||
|
||||
AttachBody.prototype._attachPositioningHandler =
|
||||
function (decorated, container) {
|
||||
var self = this;
|
||||
|
Loading…
Reference in New Issue
Block a user