Support for multiple location input controls on the same page.

Created on 5 August 2020, over 4 years ago
Updated 7 June 2024, 6 months ago

Problem/Motivation

I have a fairly niche use case that I've run into, in that the site design I'm working on calls for a location search in a mega menu and a location search on a directory page. By themselves they work fine, but since the module just uses the id of the option you chose to generate the lookup class name, if you load both of them at the same time it causes issues, because the location javascript only binds to one control. Drupal does support doing this in core, in that the form controls themselves all still have unique IDs, so I think it makes sense to support it here as well.

Proposed resolution

Instead of running the option_id though the uniqid function, first run it through Html::getUniqueId to ensure it's unique to the page, then feed that into the uniqid function. Also key the array entry into the clientLocation/geocoder arrays inside the locationInput array, so that they merge into one collection once the page loads and reads the drupalSettings. The attached patch does this and seems to work fine.

✨ Feature request
Status

Postponed: needs info

Version

3.0

Component

Javascript General / Frontend

Created by

πŸ‡ΊπŸ‡ΈUnited States jacobbell84

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024