From f19f178e3ca29cf68c73efb23b3c7564931e9581 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Mon, 30 Mar 2015 16:43:38 -0700 Subject: [PATCH] feat(search): escape will blur and clear search Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1374 --- internal_packages/search-bar/keymaps/search-bar.cson | 2 ++ internal_packages/search-bar/lib/search-bar.cjsx | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 internal_packages/search-bar/keymaps/search-bar.cson 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