Skip to content

Commit

Permalink
fix(suggest-item): highlight matches in fixtures, too
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-ka committed Jun 16, 2017
1 parent d131310 commit 698ee71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/Geosuggest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ class Geosuggest extends React.Component {
*/
updateSuggests(suggestsGoogle = [], callback) {
var suggests = [],
regex = new RegExp(escapeRegExp(this.state.userInput), 'gim'),
userInput = this.state.userInput,
regex = new RegExp(escapeRegExp(userInput), 'gim'),
skipSuggest = this.props.skipSuggest,
maxFixtures = this.props.maxFixtures,
fixturesSearched = 0,
Expand All @@ -234,6 +235,10 @@ class Geosuggest extends React.Component {

suggest.placeId = suggest.label;
suggest.isFixture = true;
suggest.matchedSubstrings = {
offset: suggest.label.indexOf(userInput),
length: userInput.length
};
suggests.push(suggest);
}
});
Expand Down
12 changes: 0 additions & 12 deletions src/suggest-item.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import classnames from 'classnames';

/**
Expand All @@ -8,16 +7,6 @@ import classnames from 'classnames';
* @return {JSX} The icon component.
*/
export default class SuggestItem extends React.Component {
/**
* Whether or not the component should update
* @param {Object} nextProps The new properties
* @param {Object} nextState The new state
* @return {Boolean} Update or not?
*/
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}

/**
* Makes a text bold
* @param {String} element The element to wrap
Expand Down Expand Up @@ -107,7 +96,6 @@ export default class SuggestItem extends React.Component {
if (this.props.renderSuggestItem) {
content = this.props.renderSuggestItem(suggest);
} else if (this.props.isHighlightMatch) {
// console.log('#', suggest);
content = this.formatMatchedText(this.props.userInput, suggest);
}

Expand Down

0 comments on commit 698ee71

Please # to comment.