Sticky actions fail on Ajax
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3503304. --> Reported by: [christianadamski](https://www.drupal.org/user/867880) Related to !572 !571 >>> <p>Look at the more_actions.js file, specifically the updateFormId() function.</p> <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const formId = form.getAttribute('id');<br> [...]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.querySelector(`[data-drupal-selector="${formId}"] [data-drupal-selector="${buttonId}"]`).click();<br> [...]</pre><p>The code assumes, that formId and data-drupal-selector are identical. Which they initially are.<br> However, after an Ajax triggered reload, they diverge.</p> <p>In our local example, form #id and data-drupal-selector initially are "node-document-edit-form"</p> <p>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.</p> <p>Under the hood, this in FormBuilder.php and Html::getUniqueId($unprocessed_id); vs Html::getId($element['#id'])</p> <p>The former creates a "--", the latter reduces it to "-".</p> <p>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.</p> > Related issue: [Issue #3499408](https://www.drupal.org/node/3499408)
issue