Turbo: Allow Ajax links and form submits to be handled by Drupal's Ajax framework

Created on 28 October 2023, 8 months ago
Updated 4 November 2023, 8 months ago

Problem/Motivation

Links and form elements that are handled by Drupal Ajax are currently broken after a Turbo navigation in that they get taken over by Turbo rather than letting Drupal's Ajax framework handle them which can result in some unexpected errors or behaviour. An example are the field UI display mode tables, which have Ajax sub-forms; Turbo attempts to submit these itself, but the response doesn't redirect so Turbo logs and error to the console and the form doesn't get updated. Another example is the Token module's token list dialog link not opening a dialog but instead navigating to the link URL via Turbo.

Steps to reproduce

Ajax behaviours are busted on admin section forms, as an example, such as field UI.

Proposed resolution

Disable Turbo handling for Ajax form elements via the data-turbo="false" attribute and disable Turbo handling of Ajax links via a document-wide turbo:click event handler.

Remaining tasks

See proposed resolution.

Also discovered that Drupal core doesn't correctly use context when attaching Ajax behaviours, so that will need to be fixed in Drupal core. See #2711821: Drupal.behaviors.AJAX.attach() doesn't use context β†’

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Ambient.Impact Toronto

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

Comments & Activities

Production build 0.69.0 2024