Ajax progress indicator on action buttons

Created on 14 November 2024, 7 days ago

Problem/Motivation

With the introduction of #3463796 Ensure sticky action buttons to work with modals and ajax refresh-calls 🐛 Ensure sticky action buttons to work with modals and ajax refresh-calls Needs review and entity form action buttons becoming <label> elements there is no longer a visible progress indicator when an ajax callback is attached to an action button. Is there a way to restore this functionality?

Steps to reproduce

- Install gin 8.x-3.0-rc14, set as admin theme
- Attach an ajax callback to e.g. the node form "Preview" button
- Observe that no progress indicator is visible:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function ajax_example_form_node_form_alter(&$form, FormStateInterface $form_state) {
  $form['actions']['preview']['#ajax'] = [
    'callback' => 'ajax_example_form_node_form_preview_callback',
    'event' => 'click',
    'progress' => [
      'type' => 'throbber',
      'message' => 'Processing...',
    ],
  ];
}

/**
 * Form submission handler for the 'preview' action.
 *
 * @param array $form
 *   An associative array containing the structure of the form.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *   The current state of the form.
 */
function ajax_example_form_node_form_preview_callback(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $response->addCommand(new AlertCommand('Do you see this?'));
  return $response;
}
Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇱🇻Latvia artis.bajars

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

Comments & Activities

Production build 0.71.5 2024