Skip to content

Commit 0fc90ec

Browse files
committed
Update select2.js
Fixing a container width problem that was caused by an inline width declaration when this.opts.width is set to "copy" (the default).
1 parent 87e6200 commit 0fc90ec

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

select2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,12 +1663,12 @@ the specific language governing permissions and limitations under the Apache Lic
16631663
}
16641664
}
16651665

1666-
// next check if css('width') can resolve a width that is percent based, this is sometimes possible
1667-
// when attached to input type=hidden or elements hidden via css
1668-
style = this.opts.element.css('width');
1669-
if (style && style.length > 0) return style;
1670-
16711666
if (this.opts.width === "resolve") {
1667+
// next check if css('width') can resolve a width that is percent based, this is sometimes possible
1668+
// when attached to input type=hidden or elements hidden via css
1669+
style = this.opts.element.css('width');
1670+
if (style.indexOf("%") > 0) return style;
1671+
16721672
// finally, fallback on the calculated width of the element
16731673
return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
16741674
}

0 commit comments

Comments
 (0)