Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
fix(UX): highlight metadata also
Browse files Browse the repository at this point in the history
fixes #157
  • Loading branch information
vvo committed May 11, 2016
1 parent 2cb1e54 commit aa88262
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/formatHit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ export default function formatHit({
}) {
try {
const name = hit.locale_names[0];
const highlightedName = hit._highlightResult.locale_names[0].value;

const administrative = hit.administrative && hit.administrative[0] !== name ?
hit.administrative[0] : undefined;
const highlightedAdministrative = administrative ?
hit._highlightResult.administrative[0].value : undefined;

const city = hit.city && hit.city[0] !== name ? hit.city[0] : undefined;
const highlightedCity = city ? hit._highlightResult.city[0].value : undefined;

const suggestion = {
name,
Expand All @@ -31,7 +37,10 @@ export default function formatHit({
const value = templates.inputValue(suggestion);
const dropdownValue = templates.dropdownSuggestion({
...suggestion,
name: hit._highlightResult.locale_names[0].value
name: highlightedName,
administrative: highlightedAdministrative,
city: highlightedCity,
country: hit._highlightResult.country.value
});

return {
Expand Down

0 comments on commit aa88262

Please sign in to comment.