Map disappears on subsequent filters when attached to a View with caching and AJAX enabled

Created on 4 August 2024, 3 months ago
Updated 23 August 2024, 3 months ago

Problem/Motivation

When a View has an attachment set to a display which use Geofield Google Map formatter and has caching enabled and AJAX enabled, the map will disappear on subsequent filter applies. The first time a filter is applied, it will work and the map updates. After the first apply, other attempts will result in the map not loading when using the same filter criteria.

Steps to reproduce

  1. Install latest Drupal 10.3 and geofield_map 3.0.20
  2. Create a new node type to store map markers with 1 geofield field
  3. Add a couple of instances of the previously created node type
  4. Create a View to show the previously created node type
  5. Create 1 display as an attachment and 1 display as a page
  6. Add a filter to the view and expose it
  7. Add the geofield field and title to the view
  8. Set the attachment display to use Geofield Google Map format and use the geofield field from before
  9. Attach the previously created attachment display to the page display
  10. Enable caching and AJAX for the view
  11. Visit the page with the view and apply the filter
  12. The first time it will work. Subsequent tries will result in the map not loading

See this screen recording for an example of the issue.

Proposed resolution

  • Remove the check for an existing entry in map_data. When the filter is applied subsequently, the mapId used is the same and an entry already exists in map_data so loadMap() does not get called resulting in a missing map.
  • Remove extra check if mapId exists in drupalSettings since it happens earlier
  • The change above will cause the map to reload everytime it comes into view if lazyload is enabled. To prevent this, use once().

See recording of proposed fix.

Remaining tasks

  • Test if there are any unintended consequences. So far works well!
🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States iamfil

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

Merge Requests

Comments & Activities

  • Issue created by @iamfil
  • 🇺🇸United States iamfil
  • 🇺🇸United States iamfil
  • 🇺🇸United States iamfil
  • Status changed to Closed: cannot reproduce 3 months ago
  • 🇮🇹Italy itamair

    Bugs cannot be reported in this easy way, with no evidence and with this clear lack of context and information.
    You don't provide:
    - any description of what you experience;
    - any clear/objective evidence that it is a general Bug, and not caused by a potential custom setup of your project environment;
    - you don't provide any information on how to clearly (and objectively) reproduce what you report ...
    - you don't also provide any screenshot go what you report, to better help who is supposed to support and re-act on this ...

    On the minimal info you provide only in your title (that you also changed) I cam say that all is working good on the Geofield Map side (
    3.0.20), on the Geofield Map View, with Proximity Filter, Ajax and Cache enable,
    as you can check from this demo Goofield Map Page: https://www.geodemocracy.com/drupal_geofield_stack_demo/web/

    Hence, I am moving this into normal Support Request and Closing as cannot reproduce.
    Please reopen this only providing proper and detailed documentation, and info on how to reproduce your use case.

    Set this as Bug ONLY if you can provide clear and objective way that it is a General Bug, and not an assumed one on something on your side that doesn't behave the way you expect (and that could depend by so many things from your setup).

  • Status changed to Active 3 months ago
  • 🇺🇸United States iamfil
  • 🇺🇸United States iamfil

    Sorry about the lack of initial information! I was interrupted while working on this.

  • 🇺🇸United States iamfil
  • 🇺🇸United States iamfil
  • Pipeline finished with Skipped
    3 months ago
    #248720
  • Status changed to Fixed 3 months ago
  • 🇮🇹Italy itamair

    thanks a lot @iamfil ... I QAed and Tested your MR!19 and it looks having much sense and not introducing any evident regression (also in the Lazy Load ...).
    thus I merged it into the 3.0.x branch. All this will be parto of the next incoming Leaflet module release,

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024