Clear search when input is empty and enter is pressed. fixes #650

This commit is contained in:
Toby Zerner
2016-01-13 10:06:04 +10:30
parent ba7fba9015
commit aaab2cc86e

View File

@ -23,7 +23,7 @@ export default class Search extends Component {
* *
* @type {Function} * @type {Function}
*/ */
this.value = m.prop(); this.value = m.prop('');
/** /**
* Whether or not the search input has focus. * Whether or not the search input has focus.
@ -131,7 +131,11 @@ export default class Search extends Component {
break; break;
case 13: // Return case 13: // Return
m.route(this.getItem(this.index).find('a').attr('href')); if (this.value()) {
m.route(this.getItem(this.index).find('a').attr('href'));
} else {
this.clear();
}
this.$('input').blur(); this.$('input').blur();
break; break;