summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-08-16 14:18:36 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2017-08-16 09:18:36 -0400
commit30cfc1aa3efcf80622b480733fd5ee763301e0ae (patch)
tree03eca3bf2f1ed53f5865cc394bf3e163479b50c3 /webapp
parentcc3d8a9180595305114a112c05274b645c6d7abe (diff)
downloadchat-30cfc1aa3efcf80622b480733fd5ee763301e0ae.tar.gz
chat-30cfc1aa3efcf80622b480733fd5ee763301e0ae.tar.bz2
chat-30cfc1aa3efcf80622b480733fd5ee763301e0ae.zip
PLT-7368: Don't clear search box on ESC in Chrome. (#7215)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/components/search_bar.jsx11
-rw-r--r--webapp/components/suggestion/suggestion_box.jsx1
2 files changed, 9 insertions, 3 deletions
diff --git a/webapp/components/search_bar.jsx b/webapp/components/search_bar.jsx
index 581fe0536..11ceaac73 100644
--- a/webapp/components/search_bar.jsx
+++ b/webapp/components/search_bar.jsx
@@ -15,7 +15,9 @@ import {getFlaggedPosts, performSearch} from 'actions/post_actions.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
-var ActionTypes = Constants.ActionTypes;
+const ActionTypes = Constants.ActionTypes;
+const KeyCodes = Constants.KeyCodes;
+
import {Tooltip, OverlayTrigger, Popover} from 'react-bootstrap';
import PropTypes from 'prop-types';
@@ -110,8 +112,11 @@ export default class SearchBar extends React.Component {
});
}
- handleKeyDown() {
- // This is just to prevent a JS error
+ handleKeyDown(e) {
+ if (e.which === KeyCodes.ESCAPE) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
}
handleChange(e) {
diff --git a/webapp/components/suggestion/suggestion_box.jsx b/webapp/components/suggestion/suggestion_box.jsx
index 2dfd2b5c5..8f50a23ef 100644
--- a/webapp/components/suggestion/suggestion_box.jsx
+++ b/webapp/components/suggestion/suggestion_box.jsx
@@ -323,6 +323,7 @@ export default class SuggestionBox extends React.Component {
e.preventDefault();
} else if (e.which === KeyCodes.ESCAPE) {
GlobalActions.emitClearSuggestions(this.suggestionId);
+ e.preventDefault();
e.stopPropagation();
} else if (this.props.onKeyDown) {
this.props.onKeyDown(e);