Focus on the wrong submit button after AJAX submit

Created on 10 September 2022, almost 2 years ago
Updated 21 May 2024, 4 months ago

Problem/Motivation

There is an unrelated webform in the footer, that has a submit button with "edit-actions-submit" selector.
And there is a Layout Builder page, where you press on the edit block and can see a form with submit button with the same "edit-actions-submit" selector.

If you submit this edit form, then the page will scroll all the way down to focus on the "edit-actions-submit" of the unrelated webform.

Steps to reproduce

- Enable Layout Builder and Webform modules.
- Create a webform and add it to the footer.
- Allow individual layouts for Page content type.
- Create a node and go to the Layout tab.
- Add a block, then try to edit it.
- When submit button is clicked, it will scroll down to the webform submit button.

Proposed resolution

The ajax.js relies on data-drupal-selector attribute to find the element focus on. Problem is that value of that attribute for form elements is sometimes not unique. It would be better to rely on the "id" attribute.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
AjaxΒ  β†’

Last updated about 20 hours ago

Created by

πŸ‡°πŸ‡¬Kyrgyzstan elaman

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom Sophie.SK

    Rerolled against 11.x, and also 10.2.x, which is the version of Drupal I'm running and needed it to be rerolled.

  • Status changed to Needs work 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks, should be converted to an MR for 11.x

    Probably can add a simple assert somewhere too to check the focus. Maybe even a nightwatch test.

Production build 0.71.5 2024