Skip to content

Commit

Permalink
suggestion fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SummySumanth committed Sep 12, 2019
1 parent 9ff1bc6 commit cc3a107
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/searchBar/searchBar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React,{ Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';

import searchBarActions from '../../actions/searchBar/searchBarActions';
import { searchIcon } from '../../assets/images/common/';
Expand Down Expand Up @@ -63,7 +64,8 @@ class SearchBar extends Component{
this.setState({
isFocused: false,
});
this.refs.input.blur()
this.props.history.push(`groups`);
this.refs.input.blur();
}
};

Expand All @@ -82,8 +84,10 @@ class SearchBar extends Component{
};

onSuggestionClickHanlder = searchParam =>{
console.log('search param received is ', searchParam);
this.props.setSearchParam(searchParam);
this.props.triggerSearch();
this.props.history.push(`groups`);
};

getSuggestionItems = (suggestionsList, searchParam) =>{
Expand Down Expand Up @@ -153,4 +157,4 @@ const mapDispatchToProps = dispatch =>({
setSearchParam : payload => dispatch(searchBarActions.setSearchParam(payload)),
triggerSearch : () => dispatch(searchBarActions.triggerSearch()),
});
export default connect(mapStateToProps, mapDispatchToProps)(SearchBar);
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(SearchBar));
2 changes: 1 addition & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const loggerMiddleware = createLogger({ predicate: () => ({ logger: console, dif

const store = createStore(
allReducers,
applyMiddleware(thunk , loggerMiddleware)
applyMiddleware(thunk )
);

ReactDOM.render(
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/suggestionStringGenerator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export default {
getHighlightText : (longString , shortString) =>{
const startOfSubstring = longString.indexOf(shortString);
if(startOfSubstring === -1){
return longString
}
const endOfSubstring = startOfSubstring + shortString.length;
return [longString.slice(0, startOfSubstring),'<strong class="FF_searchbar-suggestion-item-highlighter">', shortString,'</strong>', longString.slice(endOfSubstring)].join('');
}
Expand Down

0 comments on commit cc3a107

Please sign in to comment.