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:
- edit textfield A in form 2
- wait for AJAX callback
- 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
testimplementation- review
User interface changes
- improved accessibility