Commit 5881adda by Bill DeRusha

Merge pull request #9742 from edx/bderusha/clear-search

Add logic to handle not searching when focus is passed to the clear search button
parents da113d73 1cfadf39
......@@ -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);
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment