Handling dropdown on Esc <3

This commit is contained in:
Belen Curcio
2017-06-16 15:50:58 -03:00
parent e30d5a9c62
commit 4403decbe9
3 changed files with 10 additions and 2 deletions
@@ -67,7 +67,7 @@
}
.story {
padding: 5px 63px;
padding: 7px 63px;
border-bottom: 1px solid #ddd;
cursor: pointer;
display: block;
@@ -19,7 +19,7 @@ const StorySearch = (props) => {
return (
<div>
<div className={styles.container} role='alertdialog'>
<div className={styles.container} role='alertdialog' onKeyDown={props.handleEsc}>
<div className={styles.positionShim}>
<div className={styles.headInput}>
<input
@@ -20,6 +20,13 @@ class StorySearchContainer extends React.Component {
});
}
handleEsc = (e) => {
if (e.key === 'Escape') {
e.preventDefault();
this.props.closeSearch();
}
}
handleEnter = (e) => {
if (e.key === 'Enter') {
e.preventDefault();
@@ -43,6 +50,7 @@ class StorySearchContainer extends React.Component {
<StorySearch
search={this.search}
goToStory={this.goToStory}
handleEsc={this.handleEsc}
handleEnter={this.handleEnter}
searchValue={this.state.searchValue}
handleSearchChange={this.handleSearchChange}