diff --git a/internal_packages/search-bar/keymaps/search-bar.cson b/internal_packages/search-bar/keymaps/search-bar.cson new file mode 100644 index 000000000..a0f869032 --- /dev/null +++ b/internal_packages/search-bar/keymaps/search-bar.cson @@ -0,0 +1,2 @@ +'.search-bar input': + 'escape': 'search-bar:escape-search' diff --git a/internal_packages/search-bar/lib/search-bar.cjsx b/internal_packages/search-bar/lib/search-bar.cjsx index c500e5790..6402d753e 100644 --- a/internal_packages/search-bar/lib/search-bar.cjsx +++ b/internal_packages/search-bar/lib/search-bar.cjsx @@ -19,6 +19,9 @@ SearchBar = React.createClass @body_unsubscriber = atom.commands.add 'body', { 'application:focus-search': @_onFocusSearch } + @body_unsubscriber = atom.commands.add '.search-bar', { + 'search-bar:escape-search': @_clearAndBlur + } # It's important that every React class explicitly stops listening to # atom events before it unmounts. Thank you event-kit @@ -118,6 +121,10 @@ SearchBar = React.createClass _onClearSearch: (event) -> Actions.searchQueryCommitted('') + _clearAndBlur: -> + @_onClearSearch() + @refs.searchInput?.getDOMNode().blur() + _onFocus: -> @setState focused: true