harvesthq/chosen — pull request #1277 by rbright (2013-06-15 02:20:14+00:00)
Title: Only attempt to hide the dropdown if it's showing

There are multiple events that trigger the `results_hide` function.

1. **Expand a dropdown and close it again.** This triggers `results_hide` through the `results_toggle` function. Note that the dropdown is still highlighted.

2. **Focus on another element**. This triggers `results_hide` through the `close_field` function.

Suppose we have two Chosen dropdowns.

Expanding the first dropdown sets `@results_showing` to `true`. Closing it sets the flag to `false`. However, expanding the second dropdown will first toggle the flag to `true` but then toggle it back to `false` when `results_hide` is called as a result of `close_field`.

An example of this behavior can be seen at http://www.getharvest.com/platform.