custom ajax button not working anymore

Created on 13 January 2025, 3 months ago

Problem/Motivation

Were are using a custom submit button on the node edit page which is configured the following:

$element['emp_save_edit_ajax'] = [
      '#type' => 'submit',
      '#value' => $config->get('button_value'),
      '#submit' => [
        '::submitForm',
        '::save',
      ],
      //'#attributes' => ['class' => 'emp_save_edit_submit_ajax'],
      '#attributes' => [
        'class' => [
          'container-emp_save_edit_submit_ajax',
          'button--primary',
        ],
      ],
      '#ajax' => [
        'callback' => '::emp_save_edit_form_submit_ajax',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
      '#weight' => $config->get('button_weight'),
      '#gin_action_item' => TRUE,
    ];

Which produces this button html:

<input class="container-emp_save_edit_submit_ajax button--primary button js-form-submit form-submit" form="node-landingpage-content-edit-form" data-drupal-selector="edit-emp-save-edit-ajax" type="submit" id="edit-emp-save-edit-ajax" name="op" value="Save" data-once="drupal-ajax">

When clicking the button the a ajax request is triggered and the server side callback function`emp_save_edit_form_submit_ajax` is called - works.
With tag 3.0-rc14 (and later) the html of the button has changed and the ajax request (and also the server side callback function) is not triggered anymore
new html of button:

<input class="container-emp_save_edit_submit_ajax button--primary button js-form-submit form-submit" data-drupal-selector="gin-sticky-edit-emp-save-edit-ajax" id="gin-sticky-edit-emp-save-edit-ajax" form="node-app-storefront-content-edit-form" data-gin-sticky-form-selector="gin-sticky-edit-emp-save-edit-ajax" type="submit" name="op" value="Save">

I have boiled it down to this commit, with these changes things broke:
https://git.drupalcode.org/project/gin/-/commit/c2d182f5e0d50c8c953eb192...

I have no clue what is going and why things are not working anymore (for us).

May someone can explain

Best regards

🐛 Bug report
Status

Active

Component

Code

Created by

🇩🇪Germany skrug Bamberg

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024