react-places-autocomplete icon indicating copy to clipboard operation
react-places-autocomplete copied to clipboard

Add matching_substrings property to autocompleteItems and formattedSuggestion

Open AlyonaPianykh opened this issue 7 years ago • 3 comments

Hello!

I'm using your component and I need to highlight matching parts of predictions and user's input string. As I know, in predictions set, returned by request, there is property 'matched_substrings' with the set of matches' length and offset. Is it possible to add this property both to autocompleteItems and to formattedSuggestion, so it is possible to access matches through "render" using "autocompleteItem" property?

Or even do like this: const formattedSuggestion = (structured_formatting) => ({ mainText: structured_formatting.main_text, secondaryText: structured_formatting.secondary_text, mainTextMatchedSubstrings: structured_formatting.main_text_matched_substrings, secondaryTextMatchedSubstrings: structured_formatting.secondary_text_matched_substrings });

main_text_matched_substrings and secondary_text_matched_substrings are contained in the structured_formatting of prediction, so it is possible to add it exactly to formatting function

AlyonaPianykh avatar May 25 '17 10:05 AlyonaPianykh

@OlenaPianykh Thank you for opening this issue. I can see this feature is useful to other users too. I will add this feature. If you are interested, feel free to work on it and submit a PR too 👍

hibiken avatar May 25 '17 23:05 hibiken

Resurrecting this. I need this feature as well, so I went ahead and created the PR. The payload is coming from google so it just needed to be included in the component state.

matthewgonzalez avatar Jul 23 '18 05:07 matthewgonzalez

I left a comment on the PR and will merge once resolved! Hope you're still interested :)

sambokai avatar May 17 '20 17:05 sambokai