diff --git a/app/components/map.gjs b/app/components/map.gjs index 85e88cc..d320411 100644 --- a/app/components/map.gjs +++ b/app/components/map.gjs @@ -1191,6 +1191,12 @@ export default class MapComponent extends Component { return; } + if (this.mapUi.searchResults && this.mapUi.searchResults.length > 0) { + console.debug('Clearing active search and markers on map click'); + this.router.transitionTo('index'); + return; + } + // Require Zoom >= 17 for generic map searches // This prevents accidental searches when interacting with the map at a high level const currentZoom = this.mapInstance.getView().getZoom(); diff --git a/tests/acceptance/map-search-reset-test.js b/tests/acceptance/map-search-reset-test.js index c494290..2d324d2 100644 --- a/tests/acceptance/map-search-reset-test.js +++ b/tests/acceptance/map-search-reset-test.js @@ -101,7 +101,7 @@ module('Acceptance | map search reset', function (hooks) { 'Should have stayed on the search route with markers intact' ); - // Second Click (Start new search) + // Second Click (Clear search and markers) // Click slightly differently to ensure fresh event await triggerEvent(canvas, 'pointerdown', { clientX: 250, @@ -125,11 +125,6 @@ module('Acceptance | map search reset', function (hooks) { // 3. Wait for transition await new Promise((r) => setTimeout(r, 1000)); - const newUrl = currentURL(); - assert.notOk( - newUrl.includes('category=coffee'), - `New URL ${newUrl} should not contain category param` - ); - assert.ok(newUrl.includes('/search'), 'Should be on search route'); + assert.strictEqual(currentURL(), '/', 'Should have transitioned to index'); }); });