From 16e134d20bd9e2a2cdc2877d866a222ce93117cd Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sat, 1 Oct 2016 14:54:55 +0200 Subject: [PATCH] restore focus if chosen was activated fixes #2429 --- coffee/chosen.jquery.coffee | 5 ++++- coffee/chosen.proto.coffee | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 004e0441d6d..4e2fb882136 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -310,7 +310,10 @@ class Chosen extends AbstractChosen choice_destroy: (link) -> if this.result_deselect( link[0].getAttribute("data-option-array-index") ) - this.show_search_field_default() + if @active_field + @search_field.focus() + else + this.show_search_field_default() this.results_hide() if @is_multiple and this.choices_count() > 0 and @search_field.val().length < 1 diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index e5b1185d674..1171ee891ac 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -301,7 +301,10 @@ class @Chosen extends AbstractChosen choice_destroy: (link) -> if this.result_deselect link.readAttribute("rel") - this.show_search_field_default() + if @active_field + @search_field.focus() + else + this.show_search_field_default() this.results_hide() if @is_multiple and this.choices_count() > 0 and @search_field.value.length < 1