diff --git a/src/components/IntegrationAutosuggest.js b/src/components/IntegrationAutosuggest.js index 8b139eb5e0c3fdbba8b0b0758247a3d393b47c82..18fa3fdd50a19d356250af38c01559ab9a8651c1 100644 --- a/src/components/IntegrationAutosuggest.js +++ b/src/components/IntegrationAutosuggest.js @@ -75,10 +75,14 @@ const IntegrationAutosuggest = (props) => { const handleOnChange = (event, { newValue }) => props.updateQuery(newValue); - const handleOnSuggestionSelected = () => props.fetchResults(); + const handleOnSuggestionSelected = () => { + props.clearSuggestions(); + props.fetchResults(); + }; const handleOnKeyDown = (event) => { if (event.key === 'Enter') { + props.clearSuggestions(); props.fetchResults(); } }; diff --git a/src/epics/index.js b/src/epics/index.js index e897606b5f9079b0a4cac8d603bc699a0bef7e37..466f58442732f76e781a4f657befdab7730098a9 100644 --- a/src/epics/index.js +++ b/src/epics/index.js @@ -35,6 +35,7 @@ const getSuggestionsEpic = (action$, store) => { const getResultsEpic = (action$, store) => { const searchUrl = 'http://localhost:3000/search'; return action$.ofType(FETCH_RESULTS) + .debounceTime(500) .switchMap(() => { const { query, datasets } = store.getState().search; if (query.length < 3) { diff --git a/src/reducers/search.js b/src/reducers/search.js index 45d6d810a257856364282c5facf0e38fb1ba41bc..9f5fa0789003b71e6e2a0de5146178108310ea91 100644 --- a/src/reducers/search.js +++ b/src/reducers/search.js @@ -27,7 +27,12 @@ const search = (state = INITIAL_STATE, action) => { return { ...state, suggestions: suggestions(state.suggestions, action) }; case CLEAR_RESULTS: case UPDATE_RESULTS: - return { ...state, results: results(state.results, action) }; + return { + ...state, + suggestions: [], + results: results(state.results, action) + + }; default: return state; }