From c6974087dce6807df5b9000814e586f4eef151ae Mon Sep 17 00:00:00 2001 From: Andrew Dunkman Date: Thu, 31 Aug 2017 18:01:51 -0400 Subject: [PATCH] Only trim to container_width when calculable. --- coffee/chosen.jquery.coffee | 5 ++--- coffee/chosen.proto.coffee | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) 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 5aedd76018d..2090405db79 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -505,9 +505,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')