From 7ff1e60297fe72d4d5e22badba3a3a32119d9784 Mon Sep 17 00:00:00 2001 From: Cristen Jones Date: Thu, 19 Sep 2024 09:41:45 -0400 Subject: [PATCH] hotfix: display full address in trip planner input --- assets/js/algolia-result.js | 6 ++---- assets/js/algolia-results.js | 5 +---- assets/js/test/algolia-result_test.js | 2 +- assets/js/trip-planner-location-controls.js | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/assets/js/algolia-result.js b/assets/js/algolia-result.js index 0a13b756ed..65ad0f6d85 100644 --- a/assets/js/algolia-result.js +++ b/assets/js/algolia-result.js @@ -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 "#"; @@ -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": diff --git a/assets/js/algolia-results.js b/assets/js/algolia-results.js index 9085433b94..5e88308bfb 100644 --- a/assets/js/algolia-results.js +++ b/assets/js/algolia-results.js @@ -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( diff --git a/assets/js/test/algolia-result_test.js b/assets/js/test/algolia-result_test.js index 0783c1c46a..2eecb3dbf3 100644 --- a/assets/js/test/algolia-result_test.js +++ b/assets/js/test/algolia-result_test.js @@ -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 } diff --git a/assets/js/trip-planner-location-controls.js b/assets/js/trip-planner-location-controls.js index 4818402731..31ed420ce8 100644 --- a/assets/js/trip-planner-location-controls.js +++ b/assets/js/trip-planner-location-controls.js @@ -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,