at_core_preprocess_links() breaks ajax links

Created on 5 July 2023, over 1 year ago
Updated 7 August 2023, over 1 year ago

Problem/Motivation

The module Entity Queue creates links that use ajax to add and remove nodes from entity queues. https://www.drupal.org/project/entityqueue

With themes like claro, the links created by Entity Queue look like this:

<a href="/admin/structure/entityqueue/homepage/headline_news/7/remove-item?token=P6WaNEkJ90fJTE7E_LnCixtoXKbOt4_zofObJOsHj5w" class="use-ajax" data-once="ajax">Remove from queue</a>

With Adaptive Theme, at_core_preprocess_links() (located in adaptivetheme\at_core\includes\preprocess.inc) has line 896:

$variables['links'][$key]['link']['#options']['attributes']['class'] = [Html::cleanCssIdentifier($key . '__link')];

This overwrites the "use-ajax" class and breaks the in browser submit functionality.

Steps to reproduce

  • Install adaptivetheme / subtheme generated by adaptive theme
  • Install EntityQueue
  • Create entity queue
  • Navigate to node to add node to queue and click queue tab: node/1234/entityqueue
  • Click "add to entity queue"
  • Result: Access denied error. The node will be added to the queue, but instead of an ajax submission happening, the user follows the link directly to the ajax route.

Proposed resolution

Change line 896 of preprocess.inc to this:
$variables['links'][$key]['link']['#options']['attributes']['class'][] = Html::cleanCssIdentifier($key . '__link');

This adds the new class as intended and preserves the "use-ajax" class used to trigger an ajax event

🐛 Bug report
Status

Active

Version

4.1

Component

User Experience

Created by

🇺🇸United States rblackmore

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

Comments & Activities

Production build 0.71.5 2024