Problem/Motivation
When using an AJAX filter on a Drupal view page having auto-submit enabled, the keyboard focus is not being properly managed during the update process. After a filter selection is made, the focus remains on the parent div rather than being set to the same element / updated content. This makes it difficult for keyboard-only users and the users of assistive technology to understand the context of changes made to the view after a filter selection is made.
Issue : The Filter form is also getting re-rendered on the ajax along with the updated content. ( Failure of WCAG 2.0 Success Criterion 2.1.1 - Keyboard Accessible, and WCAG 2.0 Success Criterion 2.4.3 - Focus Order)
Steps to reproduce
- Navigate to a Drupal view page with an AJAX filter (having auto-submit enabled) using a keyboard interface.
- Select a filter option from the dropdown menu..
- Observe that the view updates with new content, but the keyboard focus on the parent div. Not on the element that triggered the AJAX update or the updated content.
Impact:
This issue affects keyboard-only users who rely on a keyboard interface to navigate and understand content on web pages. It can make it difficult or impossible for them to understand the context of changes made to the view after a filter selection is made.
Proposed resolution
When a user selects a filter option, the view should be updated with the new content, and the keyboard focus should be set to the updated content or on the element that triggered the AJAX update.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | better-exposed-filters-keyboard-focus-not-properly-managed-after-ajax-filter-selection-3360314-#8.patch | 1.58 KB | nexusnovaz |
Issue fork better_exposed_filters-3360314
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ananthakrishnan0496 commentedComment #3
lendudeHow do you enable auto-submit for filters with just Drupal core?
Comment #4
ananthakrishnan0496 commentedThe auto-submit has been enabled using Better Exposed Filters.
Comment #5
ananthakrishnan0496 commentedComment #6
w01f commentedClosing as seems to be a duplicate of https://www.drupal.org/project/better_exposed_filters/issues/3103626, which has a working patch for the expected ajax behavior on the latest 6.x dev version.
Comment #7
nitesh624This I can reproduce on 7.x version of module also.
Comment #8
nexusnovaz commentedI was also able to replicate this and made a quick patch. Will turn this into a PR shortly. Hopefully I have understood the issue and fixed it according to what others need.
Comment #9
smustgrave commentedMay be good to get a simple test case.
Comment #10
smustgrave commentedFYI patch appears to be malformed when applying. Test coverage probably can be a simple assertion added to an existing test.
Comment #13
mdranove commentedUpdated the auto_submit js and added a test.
I ran into some issues with select autosubmit more generally using the default widget and a fresh install, but it was unrelated. Might capture in a separate issue.
Comment #14
adambraun commentedI was not able to apply the patch/MR to the current release, but I was able to test it against the 7.1.x-dev branch and it did not resolve the issue for my configuration. Focus was not preserved when using a radio type control, auto-submit and ajax.
Comment #15
smustgrave commentedComment #16
mdranove commentedThe MR is only for select elements, as the repro steps state "Select a filter option from the dropdown menu.."
Radios/checkboxes are not mentioned and not covered by this.
Comment #17
smustgrave commentedAppears to be working.