From fe26b083eb830836061de1458e483782cefef424 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sun, 27 Mar 2016 15:24:37 -0400 Subject: [PATCH] Fix `dropdownAutoWidth` so it actually works Previously the `dropdownAutoWidth` option didn't work because the dropdown was being absolutely positioned, so setting the width to `auto` didn't actually have an effect. This cannot be solved by just setting the width on the container, because that is also absolutely positioned. This closes https://github.com/select2/select2/issues/3101 --- src/js/select2/dropdown/attachBody.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/select2/dropdown/attachBody.js b/src/js/select2/dropdown/attachBody.js index 967252f7..0b6d96c2 100644 --- a/src/js/select2/dropdown/attachBody.js +++ b/src/js/select2/dropdown/attachBody.js @@ -204,6 +204,7 @@ define([ if (this.options.get('dropdownAutoWidth')) { css.minWidth = css.width; + css.position = 'relative'; css.width = 'auto'; }