Drupal.behaviors.dialog.prepareDialogButtons() does not handle ajax links correctly

Created on 16 October 2023, 9 months ago
Updated 15 March 2024, 3 months ago

Problem/Motivation

When opening a form in a dialog its buttons and links in form-actions are automatically moved into .ui-dialog-buttonpane. Classes of these buttons and links are copied.

If such a link has the use-ajax class, an Javascript error occurs on clicking the automatically created button.

drupal.js?v=10.1.4:64 Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
    at new Drupal.Ajax (ajax.js?v=10.1.4:483:25)
    at Drupal.ajax (ajax.js?v=10.1.4:267:18)
    at ajax.js?v=10.1.4:335:14
    at Array.forEach (<anonymous>)
    at Drupal.ajax.bindAjaxLinks (ajax.js?v=10.1.4:307:40)
    at Object.attach (ajax.js?v=10.1.4:54:19)
    at drupal.js?v=10.1.4:166:24
    at Array.forEach (<anonymous>)
    at Drupal.attachBehaviors (drupal.js?v=10.1.4:162:34)
    at HTMLFormElement.<anonymous> (ajax.js?v=10.1.4:1362:20)

Proposed resolution

Strip the use-ajax class.

Remaining tasks

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component
Javascript 

Last updated about 9 hours ago

Created by

🇳🇱Netherlands casey

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024