allow ability to track if search input is in focused

This commit is contained in:
Sean Yesmunt 2018-05-15 00:15:35 -04:00
parent 4b53175ecd
commit 4e757cb9a2
6 changed files with 32 additions and 5677 deletions

5675
dist/bundle.js vendored

File diff suppressed because it is too large Load diff

View file

@ -94,6 +94,8 @@ export const SEARCH_SUCCESS = 'SEARCH_SUCCESS';
export const SEARCH_FAIL = 'SEARCH_FAIL';
export const UPDATE_SEARCH_QUERY = 'UPDATE_SEARCH_QUERY';
export const UPDATE_SEARCH_SUGGESTIONS = 'UPDATE_SEARCH_SUGGESTIONS';
export const SEARCH_FOCUS = 'SEARCH_FOCUS';
export const SEARCH_BLUR = 'SEARCH_BLUR';
// Settings
export const DAEMON_SETTINGS_RECEIVED = 'DAEMON_SETTINGS_RECEIVED';

View file

@ -44,7 +44,12 @@ export {
doFetchFileInfosAndPublishedClaims,
} from 'redux/actions/file_info';
export { doSearch, doUpdateSearchQuery } from 'redux/actions/search';
export {
doSearch,
doUpdateSearchQuery,
doFocusSearchInput,
doBlurSearchInput,
} from 'redux/actions/search';
export { doBlackListedOutpointsSubscribe } from 'redux/actions/blacklist';
@ -166,6 +171,7 @@ export {
selectIsSearching,
selectSearchUrisByQuery,
selectWunderBarAddress,
selectSearchBarFocused,
} from 'redux/selectors/search';
export {

View file

@ -172,3 +172,13 @@ export const doUpdateSearchQuery = (query: string, shouldSkipSuggestions: ?boole
dispatch(getSearchSuggestions(query));
}
};
export const doFocusSearchInput = () => dispatch =>
dispatch({
type: ACTIONS.SEARCH_FOCUS,
});
export const doBlurSearchInput = () => dispatch =>
dispatch({
type: ACTIONS.SEARCH_BLUR,
});

View file

@ -38,7 +38,8 @@ type SearchState = {
};
const defaultState = {
isActive: false,
isActive: false, // does the user have any typed text in the search input
focused: false, // is the search input focused
searchQuery: '', // needs to be an empty string for input focusing
suggestions: [],
urisByQuery: {},
@ -98,6 +99,15 @@ export const searchReducer = handleActions(
...state,
isActive: false,
}),
[ACTIONS.SEARCH_FOCUS]: (state: SearchState): SearchState => ({
...state,
focused: true,
}),
[ACTIONS.SEARCH_BLUR]: (state: SearchState): SearchState => ({
...state,
focused: false,
}),
},
defaultState
);

View file

@ -35,3 +35,5 @@ export const selectWunderBarAddress = createSelector(
return query;
}
);
export const selectSearchBarFocused = createSelector(selectState, state => state.focused);