Missing dependency on drupal.ajax library, leading to "Uncaught TypeError: Drupal.ajax is not a function"

Created on 30 November 2023, about 1 year ago
Updated 17 January 2024, 11 months ago

Problem/Motivation

VBO's frontUi.js calls Drupal.ajax, but views_bulk_operations.libraries.yml doesn't declare a dependency on it, so it might not be loaded when needed.

Steps to reproduce

  • Create a fresh Drupal 10.0 or later test site using the Minimal install profile
  • Enable Views, Views UI, Views Bulk Operations, and Devel Generate
  • Create a content type
  • Use Devel Generate to generate more than 10 nodes
  • Create a Content view, page display, table format, with pager (10 to a page)
  • Add the "Views bulk operations (Global)" field and enable at least 1 action
  • Save the view
  • Create a non-admin user
  • Log in as the non-admin user
  • Go to the view and click on one of the VBO checkboxes — the console shows Uncaught TypeError: Drupal.ajax is not a function, and the submit button has no effect ❌

Proposed resolution

Add core/drupal.ajax to views_bulk_operations.libraries.yml.

Remaining tasks

Review patch.

User interface changes

n/a

API changes

n/a

Data model changes

n/a

🐛 Bug report
Status

Fixed

Version

4.2

Component

Core

Created by

🇺🇸United States smokris Athens, Ohio, USA

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

Comments & Activities

  • Issue created by @smokris
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    15 pass
  • 🇺🇸United States smokris Athens, Ohio, USA

    Patch attached.

  • 🇮🇳India sijumpk

    Tried recreating the error (without patch), but things are working fine. Upon checking the page source, the script /core/misc/ajax.js?v=10.1.6 is getting loaded in the page, which contains Drupal.ajax. It seems like things are working as expected even without the patch. Created the screen recording as a non-admin user, let me know if I missed something.

    Drupal version used is 10.1.6 and VBO version 4.2.x-dev.

  • Status changed to Needs work 12 months ago
  • 🇵🇱Poland Graber

    Maybe I misunderstood something.. if you cannot reproduce the error, why the "needs work" status?

  • Status changed to Active 12 months ago
  • 🇮🇳India sijumpk

    @Graber, there is nothing you missed. Just changed the status from "Needs Review", may be "Active" is better. By doing so, some others can also try to reproduce the error. Or you can change it to "Postponed (maintainer needs more info)"

  • Status changed to Needs review 12 months ago
  • 🇵🇱Poland Graber

    Ok, why did you change it to "Needs work"? Doesn't the patch solve the issue? If it does, it should be RTBC.

  • 🇮🇳India sijumpk

    Even without patch, things are working fine. So was not even able to reproduce the bug. The screen recording I provided is taken without applying any patch. So according to me the functionality is working as designed, and there is no need for the patch. There by not review needed and no RTBC.

    Followed all the steps provided in the issue summary for reproducing the bug. If in case I missed something, it will be helpful if @smokris can provide some more details. Or may be someone else can try to recheck for the existence of this bug.

  • 🇵🇱Poland Graber

    Thank you for checking.

    I checked libraries in core and all have that dependency explicitly set where applicable so I think we should include it here as well.

  • Status changed to RTBC 11 months ago
  • 🇷🇸Serbia holo96

    Just had this issue.
    Patch resolved it.

    It is possible that earlier versions of Drupal core included this library anyway, because it was working fine before.

  • Status changed to Fixed 11 months ago
  • 🇵🇱Poland Graber

    Thanks all, committed.

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

Production build 0.71.5 2024