export function search (query, baseComponent) {
return dispatch => {
dispatch(updateQueryAction(query));
- debouncedSearch(query, baseComponent, dispatch);
+
+ if (query.length > 2 || !query.length) {
+ debouncedSearch(query, baseComponent, dispatch);
+ }
};
}
*/
import React, { Component } from 'react';
import { connect } from 'react-redux';
+import classNames from 'classnames';
import { search, selectCurrent, selectNext, selectPrev } from '../actions';
+import { translateWithParameters } from '../../../helpers/l10n';
class Search extends Component {
dispatch(selectNext());
break;
default:
- // do nothing
+ // do nothing
}
}
render () {
const { query } = this.props;
+ const inputClassName = classNames('search-box-input', {
+ 'touched': query.length > 0 && query.length < 3
+ });
return (
<form
onKeyDown={this.handleKeyDown.bind(this)}
onChange={this.handleSearch.bind(this)}
value={query}
- className="search-box-input"
+ className={inputClassName}
type="search"
name="q"
placeholder="Search"
maxLength="100"
autoComplete="off"/>
+ <div className="note">
+ {translateWithParameters('select2.tooShort', 3)}
+ </div>
</form>
);
}