Skip to content

Commit

Permalink
added custom label
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmullins committed Sep 22, 2015
1 parent 30cbcc8 commit 5103598
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Geosuggest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var Geosuggest = React.createClass({
onFocus: noop,
onBlur: noop,
onChange: noop
getPlaceLabel: null
};
},

Expand Down Expand Up @@ -130,7 +131,8 @@ var Geosuggest = React.createClass({
}

var suggests = [],
regex = new RegExp(this.state.userInput, 'gim');
regex = new RegExp(this.state.userInput, 'gim'),
getPlaceLabel = this.props.getPlaceLabel;

this.props.fixtures.forEach(function(suggest) {
if (suggest.label.match(regex)) {
Expand All @@ -140,8 +142,9 @@ var Geosuggest = React.createClass({
});

suggestsGoogle.forEach(function(suggest) {
var label = getPlaceLabel ? getPlaceLabel(suggest) : suggest.description;
suggests.push({
label: suggest.description,
label: label,
placeId: suggest.place_id
});
});
Expand Down

0 comments on commit 5103598

Please sign in to comment.