Focus lost/changed after ajax refresh

Created on 8 August 2023, about 1 year ago
Updated 17 January 2024, 10 months ago

Problem/Motivation

After submitting a view with exposed filter with ajax enabled, the focus does not stay on the submit button. This is getting flagged as an accessibility issue.

Currently ajax.js looks through the `elementParents` of the element that triggered the ajax call (in this case a submit input) and looks in the page for the same `data-drupal-selector` value to move the focus to. This has changed with a new hash on the submit. So focus will no longer be on the Submit input. It moves to the second item in `elementParents` which is a `div` where the `data-drupal-selector="edit-actions"` does not have a hash. So it tries to set focus on this div which can't take focus.

Feedback from accessibility

Steps to reproduce

  1. Create view with exposed filter using ajax.
  2. Tab to Submit button
  3. Submit form
  4. Submit button does not have focus

Proposed resolution

  1. Update ajax.js to check if element is actually focusable before trying to set focus and if not look at children for focusable item (ideally the item that had focus)
  2. Possibly update to use `context` to only search the updated markup to apply focus not full `document`.
  3. Search for non hashed part of the `data-drupal-selector` string possibly if able to not search full `document`

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 6 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States madhaze

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

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024