Problem/Motivation
Leaflet field form map widget is not loading first time editing new/existing child node from inline-entity-form UI
Leaflet map doesn't load correctly first time when when editing a new or existing node from within a parent node using inline-entity-form.
On first access it shows none of the form controls i set in configuration and doesnt center the map to the coords set in the field configuration. If I cancel the current operation and re-enter the same node, the map centers and controls correctly.
This issue affects the leaflet field form widget accessed from inline-entity-forms. This issue does not affect the leaflet field form widget in the code node editor.
Steps to reproduce
- Create a content type A and add a leaflet map field.
- Configure the field with center coordinates and turn on ALL controls.
- Create a parent content type B with an multi-entity-ref field pointing to content type A
- Set the form config for the entityref content type A field to use IEF widget
- Create new node from content type A note form and display work as expected through the node/edit URL
- Create new node from content type B and add a new node of type A to it.
- "Create new node" of content type A within content type B.
- Note that the Leaflet map does not center and there are no controls.
- Cancel the operation.
- Reselect "create new node" and note that the map works ok on second load
- Enter any data, pick a known map position, save the child and parent nodes
- Reload the content type B page.
- Edit the new child node through the IEF interface.
- Note that the Leaflet map does not center and there are no controls.
- Reaccess the existing child node through the IEF interface.
- Note that the leaflet map centers and the controls are rendered correctly.
Proposed resolution
Current workaround: the first operation through the IEF interface fails. I have to cancel the first attempt and retry. Eliminate the redundant stage so that the map loads correctly first time.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | leaflet-3179158-leaflet-widget-via-ajax.patch | 529 bytes | tobiasb |
Comments
Comment #2
Syntapse commentedComment #3
itamair commentedYes ... I have experiencing this too, and inspected ... but I couldn't find any viable solution.
Any solid fixing patch (strictly not regressive and Drupal/php coding standards compliant) will be super welcome ...
Comment #4
matthiasm11 commentedInstalling the patch from #218 of https://www.drupal.org/project/drupal/issues/1988968 did the trick in my case. (leaflet widget in an "add another paragraph")
Comment #5
tobiasbI believe I have a solution / workaround for #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS. I my case map.pm was not initialized in quick-edit. But when I load geoman already with leaflet-drupal, the geoman is initialized.
And I added more deps to the leaflet-widget lib.
In the use case, hide map when empty + quickedit then you need the solution of #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS.
What I did not test is to load js from locally not from cdn.
Comment #6
nod_Core issue is now fixed for 9.5+ branches :)