Skip to content

Commit

Permalink
hotfix: display full address in trip planner input
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen committed Sep 19, 2024
1 parent 88fad7c commit 7ff1e60
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
6 changes: 2 additions & 4 deletions assets/js/algolia-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ export function getUrl(hit, index) {
return _contentUrl(hit);

case "locations":
return `transit-near-me?address=${encodeURIComponent(
hit.street_address
)}`;
return `transit-near-me?address=${encodeURIComponent(hit.formatted)}`;

case "usemylocation":
return "#";
Expand Down Expand Up @@ -345,7 +343,7 @@ export function getTitle(hit, type) {
switch (type) {
case "locations":
// eslint-disable-next-line no-case-declarations
const { street_address: text, highlighted_spans: spans } = hit;
const { formatted: text, highlighted_spans: spans } = hit;

return highlightText(text, spans);
case "stops":
Expand Down
5 changes: 1 addition & 4 deletions assets/js/algolia-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ export class AlgoliaResults {
results.locations.hits.forEach((hit, idx) => {
const elem = document.getElementById(`hit-location-${idx}`);
if (elem) {
elem.addEventListener(
"click",
this._locationSearch(hit.street_address)
);
elem.addEventListener("click", this._locationSearch(hit.formatted));
}
});
const useLocation = document.getElementById(
Expand Down
2 changes: 1 addition & 1 deletion assets/js/test/algolia-result_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe("AlgoliaResult", () => {
};
const locationHits = {
bostonCommon: {
street_address: "Boston Common, Tremont Street, Boston, MA, USA",
formatted: "Boston Common, Tremont Street, Boston, MA, USA",
highlighted_spans: [
{ length: 2, offset: 3 },
{ length: 5, offset: 9 }
Expand Down
4 changes: 2 additions & 2 deletions assets/js/trip-planner-location-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ export class TripPlannerLocControls {
);
break;
case "locations":
MapsHelpers.lookupPlace(hit.street_address).then(res => {
MapsHelpers.lookupPlace(hit.formatted).then(res => {
// this doesnt work
const { latitude, longitude } = res;
this.setStopValue(ac, hit);
this.setAutocompleteValue(
ac,
hit.street_address,
hit.formatted,
lat,
lng,
latitude,
Expand Down

0 comments on commit 7ff1e60

Please sign in to comment.