Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Handle enter keypress in quick search field
Browse files Browse the repository at this point in the history
  • Loading branch information
romangetman authored and indeyets committed Feb 13, 2017
1 parent 022a52d commit 4b9d142
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/search.js
Expand Up @@ -18,7 +18,7 @@
import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { Link, browserHistory } from 'react-router';
import { debounce, take } from 'lodash';

import { ArrayOfGeotags as ArrayOfGeotagsPropType } from '../prop-types/geotags';
Expand Down Expand Up @@ -136,6 +136,15 @@ class Search extends Component {
}
};

onKeyDown = (e) => {
if (e.keyCode === 13) {
browserHistory.push({
pathname: '/search',
query: { q: this.state.query }
});
}
};

renderResults = () => {
const { results } = this.props;
const { isOpened, query } = this.state;
Expand Down Expand Up @@ -235,6 +244,7 @@ class Search extends Component {
value={query}
onChange={this.updateQuery}
onClick={this.actionClick}
onKeyDown={this.onKeyDown}
/>
{!loading &&
<Icon
Expand Down

0 comments on commit 4b9d142

Please sign in to comment.