fix: ignore input elements except in search (#37145)

This commit is contained in:
Oliver Eyton-Williams
2019-10-09 15:58:31 +02:00
committed by mrugesh
parent 2955bbeb4f
commit 52653c57fc

View File

@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { SearchBox } from 'react-instantsearch-dom'; import { SearchBox } from 'react-instantsearch-dom';
import { HotKeys, configure } from 'react-hotkeys'; import { HotKeys, ObserveKeys } from 'react-hotkeys';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { import {
@ -19,9 +19,6 @@ import SearchHits from './SearchHits';
import './searchbar-base.css'; import './searchbar-base.css';
import './searchbar.css'; import './searchbar.css';
// Configure react-hotkeys to work with the searchbar
configure({ ignoreTags: ['select', 'textarea'] });
const propTypes = { const propTypes = {
innerRef: PropTypes.object, innerRef: PropTypes.object,
isDropdownEnabled: PropTypes.bool, isDropdownEnabled: PropTypes.bool,
@ -187,14 +184,16 @@ class SearchBar extends Component {
<label className='fcc_sr_only' htmlFor='fcc_instantsearch'> <label className='fcc_sr_only' htmlFor='fcc_instantsearch'>
Search Search
</label> </label>
<SearchBox <ObserveKeys>
focusShortcuts={[83, 191]} <SearchBox
onChange={this.handleChange} focusShortcuts={[83, 191]}
onFocus={this.handleFocus} onChange={this.handleChange}
onSubmit={this.handleSearch} onFocus={this.handleFocus}
showLoadingIndicator={true} onSubmit={this.handleSearch}
translations={{ placeholder }} showLoadingIndicator={true}
/> translations={{ placeholder }}
/>
</ObserveKeys>
{isDropdownEnabled && isSearchFocused && ( {isDropdownEnabled && isSearchFocused && (
<SearchHits <SearchHits
handleHits={this.handleHits} handleHits={this.handleHits}