From c33f8e0f3814e42fa82354ce2ded0fd47184252b Mon Sep 17 00:00:00 2001 From: Andrew Stoker Date: Sun, 28 Jul 2019 15:00:37 -0400 Subject: [PATCH] Fix dropdown positioning when displayed above with messages This fixes an issue which was usually observed when working with AJAX results sets and having a message being displayed, usually the minimum characters message or an error. The dropdown would display up, like it was supposed to, but the message would appear to be floating above the container and detached. This was occuring because the dropdown position was not being calculated whenever a message was displayed in the results, only when the results were loaded or new results were appended to an existing results set. There are plenty of situations where this could have caused issues, but somehow most of the reports were around a very specific situation with AJAX which could be reproduced on the examples site. Fixes #4614 Fixes #4616 Fixes #5253 Closes #5196 --- src/js/select2/dropdown/attachBody.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/js/select2/dropdown/attachBody.js b/src/js/select2/dropdown/attachBody.js index 12d9ad1f9f..6cc279b77b 100644 --- a/src/js/select2/dropdown/attachBody.js +++ b/src/js/select2/dropdown/attachBody.js @@ -33,6 +33,11 @@ define([ self._resizeDropdown(); }); + container.on('results:message', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); + container.on('select', function () { self._positionDropdown(); self._resizeDropdown();