From 1cfadf39cc5b3a628f9668758bb0b3a63c3c10e0 Mon Sep 17 00:00:00 2001 From: Bill DeRusha Date: Mon, 14 Sep 2015 11:08:33 -0400 Subject: [PATCH] Add logic to handle not searching when focus is passed to the clear search button TNL-3238 --- .../common/js/components/views/search_field.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/static/common/js/components/views/search_field.js b/common/static/common/js/components/views/search_field.js index 7599edee35..955133fe1c 100644 --- a/common/static/common/js/components/views/search_field.js +++ b/common/static/common/js/components/views/search_field.js @@ -14,12 +14,15 @@ 'submit .search-form': 'performSearch', 'blur .search-form': 'onFocusOut', 'keyup .search-field': 'refreshState', - 'click .action-clear': 'clearSearch' + 'click .action-clear': 'clearSearch', + 'mouseover .action-clear': 'setMouseOverState', + 'mouseout .action-clear': 'setMouseOutState', }, initialize: function(options) { this.type = options.type; this.label = options.label; + this.mouseOverClear = false; }, refreshState: function() { @@ -43,10 +46,18 @@ return this; }, + setMouseOverState: function(event) { + this.mouseOverClear = true; + }, + + setMouseOutState: function(event) { + this.mouseOverClear = false; + }, + onFocusOut: function(event) { // If the focus is going anywhere but the clear search // button then treat it as a request to search. - if (!$(event.relatedTarget).hasClass('action-clear')) { + if (!this.mouseOverClear) { this.performSearch(event); } },