AJAX focus does not work with multiple forms of the same type

Created on 5 November 2024, 10 days ago

Problem/Motivation

The Drupal AJAX re-focus logic does not work if the relevant form is instanced multiple times on the same page.

Only the first instance is automatically focused.

Steps to reproduce

On a page with duplicated AJAX forms, in which editing textfield A causes an AJAX callback which re-focuses textfield A afterwards:

  1. edit textfield A in form 2
  2. wait for AJAX callback
  3. expect focus to be in textfield A of form 2, see that the actual focus is in textfield A of form 1

Proposed resolution

Adjust the re-focusing logic to respect the index of the original element. this might break if the AJAX callback causes the page to have a different number of form instances. But I suspect this case does not really happen.

Remaining tasks

  • test
  • implementation
  • review

User interface changes

  • improved accessibility
πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

ajax system

Created by

πŸ‡©πŸ‡ͺGermany tgauges

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