Sticky actions fail on Ajax

Created on 30 January 2025, 2 months ago

Look at the more_actions.js file, specifically the updateFormId() function.

        const formId = form.getAttribute('id');
 [...]
              document.querySelector(`[data-drupal-selector="${formId}"] [data-drupal-selector="${buttonId}"]`).click();
 [...]

The code assumes, that formId and data-drupal-selector are identical. Which they initially are.
However, after an Ajax triggered reload, they diverge.

In our local example, form #id and data-drupal-selector initially are "node-document-edit-form"

After Ajax, they are "node-document-edit-form--4fZYYVW-UEc" and "node-document-edit-form-4fZYYVW-UEc" respectively. Note the "--" vs "-" before the random String.

Under the hood, this in FormBuilder.php and Html::getUniqueId($unprocessed_id); vs Html::getId($element['#id'])

The former creates a "--", the latter reduces it to "-".

So, the code needs to either query by ID instead of data-drupal-selector, or get the selector by ID first, and then use that next.

🐛 Bug report
Status

Active

Component

Code

Created by

🇩🇪Germany christianadamski Berlin, Germany

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