Skip to content

fix: sync listing address autocomplete with map pin - #3032

Open
RabbiIslamRony wants to merge 2 commits into
sovware:developmentfrom
RabbiIslamRony:fix/3332-location-map-sync
Open

RabbiIslamRony wants to merge 2 commits into
sovware:developmentfrom
RabbiIslamRony:fix/3332-location-map-sync

Conversation

@RabbiIslamRony

Copy link
Copy Markdown
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

The Google address autocomplete could be initialized more than once. After selecting a suggestion, the address field could change while the map retained its previous marker. The address field also stopped loading Google Places suggestions when the map field was removed from the listing form.

This PR:

  • makes the Google autocomplete/map setup idempotent;
  • replaces the active marker after an autocomplete selection and recenters the map;
  • loads the map provider scripts for the standalone address field;
  • keeps autocomplete and coordinate updates working when no map field is present;
  • uses the supported AdvancedMarkerElement.map = null API when removing markers.

How to reproduce / test

  1. Configure Google Maps and add both Address and Map fields to a listing form.
  2. Open the frontend listing submission form and select an address autocomplete suggestion.
  3. Confirm the latitude/longitude, map center, and marker all update to the selected place, with only one active marker.
  4. Remove the Map field while keeping the Address field.
  5. Confirm address suggestions still appear and selection still updates the stored coordinates.

Before and after

The before image is the client-provided failure case. The after image is an isolated browser replay on the same form using the fixed bundle; no client-site files or settings were changed.

Before After
Before: selected Brits address while marker remains in Cape Town After: selected Bronkhorstspruit address and marker are synchronized

Verification

  • npm run build-legacy
  • focused runtime harness covering duplicate initialization, marker replacement, map recentering, and address-only autocomplete
  • php -l includes/asset-loader/init.php
  • git diff --check
  • browser verification on the affected frontend flow

Any linked issues

TeamSync: #3332 — Location field updates, map pin fails

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant