Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-8575: Added ability to reload google maps library with correct API key #5683

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

roma-formio
Copy link
Contributor

@roma-formio roma-formio commented Jul 9, 2024

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-8575

Description

Issue: When integrating the Google Maps provider into the address component, the script for Google Maps is loaded with the URL including the API key. However, during the creation of an address component with the Google Maps provider, the library is loaded without an API key due to the preview modal executing the code to load the library. This results in the Google Maps library being loaded without the API key, and subsequent updates to the API key do not affect the already loaded library. Consequently, Google Maps continues to operate without the API key across web pages, unless a full page reload is performed.

Solution: The solution involves a method to verify if the Google Maps library has already been loaded by inspecting the src attribute of the script for the correct API key. If the script is found with an incorrect or missing API key, the method proceeds to remove all Google Maps scripts and clear related global properties. This approach ensures that the library can be correctly reloaded with the updated API key, allowing for changes to the API key to be accurately reflected without necessitating a page reload. This is achieved through a function that checks for the presence of the Google Maps script with the expected API key and, if not found as expected, removes the script and any related global properties to allow for a fresh load with the correct settings.

How has this PR been tested?

Manually.

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

@johnformio johnformio merged commit b68cd85 into master Jul 11, 2024
5 checks passed
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.

2 participants