From 4b9d14287e321bd3e2e0d65b359343ce1353a103 Mon Sep 17 00:00:00 2001 From: Roman Getman Date: Fri, 10 Feb 2017 17:44:34 +0200 Subject: [PATCH] Handle enter keypress in quick search field --- src/components/search.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/search.js b/src/components/search.js index b8864c30..2c1585a1 100644 --- a/src/components/search.js +++ b/src/components/search.js @@ -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'; @@ -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; @@ -235,6 +244,7 @@ class Search extends Component { value={query} onChange={this.updateQuery} onClick={this.actionClick} + onKeyDown={this.onKeyDown} /> {!loading &&