Problem/Motivation

This is a followup to #3443571-36: Mobile version of Navigation should have focus trap, but it should be released along with that issue.

the close button should be reachable by keyboard same as there should be an option to close the mobile navigation by pressing the ESC key. but from my perspective if moved to a follow up those followup(s) and this issue should go into the same new version of drupal.

I've limited the scope to the close button because changing it looks quick and easy, and @rkoller told me that ESC already has another function.

Setting to Major priority because removing the "Expand sidebar" button from the tab sequence in #3443571: Mobile version of Navigation should have focus trap may remove the only mechanism for closing the sidebar by keyboard.

Personally, I consider this change to be within the scope of that issue for the same reason.

WCAG success criteria

SC 2.1.1 Keyboard (Level A).

Steps to reproduce

  1. Enable the Navigation module.
  2. Log in as admin.
  3. Reduce the viewport width until the Navigation "Expand sidebar" button appears at top-left.
  4. Activate the "Expand sidebar" button to open the sidebar.
  5. Press the TAB key until the focus reaches the first menu item in the sidebar. Currently, the first menu item is "Shortcuts".
Expected behavior

The sidebar close button receives focus before the first menu item receives focus.

Actual behavior

Focus bypasses the close button and goes straight to the first menu item.

Note: The focus indicator for the Home link (Drupalicon) at the top of the sidebar is currently broken.

Proposed resolution

Remove 'tabindex': '-1', from the corresponding line in navigation.html.twig.

Remaining tasks

User interface changes

The close button will be reachable by keyboard with the TAB key.

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3572169

Command icon 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

kentr created an issue. See original summary.

kentr’s picture

Issue summary: View changes
Issue tags: +Needs screenshots

kentr’s picture

Seeking feedback before writing tests.

Maybe doesn't need screenshots.

kentr’s picture

Title: Put the "mobile" sidebar close button into the TAB sequence » Put the mobile sidebar close button into the TAB sequence
kentr’s picture

Issue summary: View changes
rkoller’s picture

In discussion with @katannshaw, @mgifford, @mherchel, and myself, we considered this follow up to the focus trap issue as a blocker in #3391723: [PLAN] Accessibility review for new Navigation bar

p.s. not sure if we should keep the focus trap issue as the parent or better move it to related issues and make the a11y meta the parent instead?

smustgrave’s picture

This change actually seems small enough that I think manual testing should be enough

rkoller’s picture

i've just manually tested, everything works as expected now. the only thing i wonder about. at the moment the close button is placed second, in the tab order within the mobile menu, right after the logo, then the rest of the menu items is placed. would it make sense to place it in the tab order between the last menu item and the logo again? cuz a screenreader user expanded the menu intentionally so the odds are low that the person directly wants to close it again? and on the other hand there is also the option to close the menu by the esc button in case they change their mind (when the related issue gets in).

kentr’s picture

@rkoller

p.s. not sure if we should keep the focus trap issue as the parent or better move it to related issues and make the a11y meta the parent instead?

Yes. I did that to tie this to the focus trap issue, but y'all made it an official higher-level blocker.

at the moment the close button is placed second, in the tab order within the mobile menu, right after the logo, then the rest of the menu items is placed. would it make sense to place it in the tab order between the last menu item and the logo again? cuz a screenreader user expanded the menu intentionally so the odds are low that the person directly wants to close it again? and on the other hand there is also the option to close the menu by the esc button in case they change their mind (when the related issue gets in).

Do you consider that to be a blocker? What are your thoughts about doing it as a followup?

This change actually seems small enough that I think manual testing should be enough

Well, color me surprised! 😃

It might be quick to add a check that the close button has the correct (or absent) value for tabindex. At least, I'll add a comment to the file that the close button is intentionally included in the tab sequence to help prevent a regression.

rkoller’s picture

thanks for relinking the issues! and in regard to the position of the close button in the tabbing order. i dont wanted to imply it should be a blocker at all. i was just thinking out loud and was curious what others think. to me on second thought it just feels like there is no perfect solution in particular due to the fact that this is not a dialog modal. you could find for potential approach pro and cons. so i guess for now best might be to stick with the dom order like you did. eric bailey wrote something in that vein recently https://ericwbailey.website/published/you-probably-shouldnt-be-annotatin.... and a +1 for at least adding a comment to prevent any regression.

mherchel’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs tests
StatusFileSize
new1.86 MB

This looks great to me. The close button is focused after the logo, which is expected.

I also

Tested to ensure the button does not receive focus when the drawer is closed
Tested to ensure the button doesn't receive focus at desktop widths.

I also agree that this does not need tests. This is not something that is likely to break.

Video attached.

kentr’s picture

Status: Reviewed & tested by the community » Needs work

I'm still going to add a comment to the file.

For the record, I disagree about tests. I consider the issue to be a fundamental part of proper dialog behavior. I'll leave the decision to others, though.

kentr’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new18.98 KB

Here's a static screenshot of the focused close button after adding the comment, just to show the general visual.

  • catch committed 7b2531c3 on 11.3.x
    task: #3572169 Put the mobile sidebar close button into the TAB sequence...

  • catch committed 5b57474a on 11.x
    task: #3572169 Put the mobile sidebar close button into the TAB sequence...

  • catch committed 21329825 on main
    task: #3572169 Put the mobile sidebar close button into the TAB sequence...
catch’s picture

Version: main » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to main, 11.x, and 11.3.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.