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.

Comments

jacobbell84 created an issue. See original summary.

jacobbell84’s picture

studgate’s picture

Updates to the patch for the latest version

uditrawat’s picture

StatusFileSize
new2.79 KB

Minor fix on the patch.

christianadamski’s picture

Status: Needs review » Postponed (maintainer needs more info)

Is this well enough tested to be merged? It is separately fixed in v4.

carma03’s picture

@ChristianAdamski just in case, the patch 3163657-4.patch could not be applied at least since 3.7 version.

christianadamski’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

This is fixed in 4.x already and won't ne handled anymore in 3.x

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.