diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index a8ba80d528a..203af36aeda 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -500,9 +500,8 @@ class Chosen extends AbstractChosen width = div.width() + 25 div.remove() - container_width = @container.outerWidth() - - width = Math.min(container_width - 10, width) + if @container.is(':visible') + width = Math.min(@container.outerWidth() - 10, width) @search_field.width(width) diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index 86ba904fa44..654a905507f 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -499,9 +499,8 @@ class @Chosen extends AbstractChosen width = div.measure('width') + 25 div.remove() - container_width = @container.getWidth() - - width = Math.min(container_width - 10, width) + if container_width = @container.getWidth() + width = Math.min(container_width - 10, width) @search_field.setStyle(width: width + 'px')