Search: clear search when backspaced all the way

This commit is contained in:
Alex Gleason 2021-11-15 15:31:32 -06:00
parent e46e217d57
commit 2c1e6d12f9
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -17,9 +17,16 @@ export const SEARCH_EXPAND_SUCCESS = 'SEARCH_EXPAND_SUCCESS';
export const SEARCH_EXPAND_FAIL = 'SEARCH_EXPAND_FAIL';
export function changeSearch(value) {
return {
type: SEARCH_CHANGE,
value,
return (dispatch, getState) => {
// If backspaced all the way, clear the search
if (value.length === 0) {
return dispatch(clearSearch());
} else {
return dispatch({
type: SEARCH_CHANGE,
value,
});
}
};
}
@ -33,6 +40,7 @@ export function submitSearch() {
return (dispatch, getState) => {
const value = getState().getIn(['search', 'value']);
// An empty search doesn't return any results
if (value.length === 0) {
return;
}