doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 8 forks source link

Address field dissapears on the editor slideout editor when static #69

Closed myleshyson closed 1 year ago

myleshyson commented 1 year ago

This one's kind of hard to explain but I'll do my best here. If a user only has view permissions on an element that has a google maps address field, when opening the slide out editor for that element a second time, the field disappears. This does not appear to be an issue when a user has full permissions to edit the element in the slide out editor

https://user-images.githubusercontent.com/11747187/199534636-4b6d8382-ed8b-4e5c-b796-19cce9bb1cc4.mov

Craft Pro 4.3.1 Google Maps 4.2.5

myleshyson commented 1 year ago

I think it has something to do with the way that {% js %} tag is handled for the slide out editor, in templates/address/index.twig.

If I replace that twig tag with the following, the address field loads every time as expected.

{# If the library is loaded, initialize all Address fields #}
{#{% js 'if (window.google) {initAddressField();}' %}#}

<script>
  if (window.google) { initAddressField(); }
</script>
kylecotter commented 1 year ago

Hey @lindseydiloreto, I'm seeing this behavior too, but in a more generic context than the original poster.

For me it's any time a slideout is triggered more than once at the root level, or when a Map field loads via a nested slideout the field doesn't render. Definitely concur it seems related to how the JS gets fired in these contexts.

Thanks!

Craft Pro 4.3.8.2 Google Maps 4.3.1

lindseydiloreto commented 1 year ago

Hey @myleshyson, thanks for reporting this issue! Sorry this slipped through the cracks.

And thanks for the nudge @kylecotter. This ticket should probably be a high priority (alongside a few other tickets on the Address field).

Thanks also for the code suggestion @myleshyson! I'll give that a shot when I dive in. 👍

lindseydiloreto commented 1 year ago

This has been fixed in v4.3.3. Thanks again for reporting it! 👍