Missing underscore library

Created on 29 June 2022, over 2 years ago
Updated 25 February 2023, over 1 year ago

Problem/Motivation

After upgrading to Drupal 9.4.1 and Geofield Map 8.x-2.82, pages that used to have maps were no longer showing maps.
The following js error was evident:
"Uncaught ReferenceError: _ is not defined at geofield_map_gmap_formatter.js 115:9".
Upon investigation I discovered that underscore.js was loading when logged in as admin, but not when using the page as anonymous user.

Steps to reproduce

On a site with core 9.4.1 and Geofield Map 8.x-2.82, insert a View with format "Geofield Google Map" that displays content with geo locations. The map will not show when the user is not logged.

Proposed resolution

It appears that Drupal Core does not load underscore.js for anonymous users. This issue can be remediated by adding a dependency on core/underscore in geofield_map.libraries.yml. For example:

geofield_google_map:
  ~
  dependencies:
      - core/jquery
      - core/once
      - core/drupal
      - core/drupalSettings
      - core/underscore

Remaining tasks

Patch the libraries.yml file.

User interface changes

Nil

API changes

Nil

Data model changes

Nil

🐛 Bug report
Status

Fixed

Version

2.82

Component

Code

Created by

🇦🇺Australia Bagz

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024