Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User focus is lost when exiting Account Menu (Accessibility) #6635

Closed
tofumatt opened this issue Feb 23, 2023 · 2 comments
Closed

User focus is lost when exiting Account Menu (Accessibility) #6635

tofumatt opened this issue Feb 23, 2023 · 2 comments
Labels
Exp: SP Good First Issue Good first issue for new engineers P1 Medium priority Type: Bug Something isn't working

Comments

@tofumatt
Copy link
Collaborator

tofumatt commented Feb 23, 2023

Bug Description

After exiting the Account Menu (using the Escape key), no element on the screen is focused and the user must press Tab or Shift + Tab to get an element on the page to appear focused.

Steps to reproduce

  1. Using keyboard navigation, tab to the user account menu in the top-right of the screen.
  2. Open the menu.
  3. Move through the menu with the keyboard.
  4. Press "Escape" to exit the menu.
  5. Focus is expected to be on the user account menu, but it is not focused. There is no visual representation of focus state, and the user must tab to restore a visual focus state.

Screenshots

Focus.lost.when.exiting.Account.Menu.mp4

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The Account Menu button next to the help button should be focused (including being visibly focused with a visible focus state) when the user exits the Account dropdown menu using the "Escape" key to close the menu.
    • If the user clicks away from the menu, it would be acceptable to blur the focus state, but if they exit the menu with keyboard input (using the Escape key explicitly), the user menu button should definitely be focused afterward.

Implementation Brief

  • In assets/js/components/UserMenu/index.js
    • Create a new menuButtonRef const that serves as a ref for the Button using useRef()
    • Assign this menuButtonRef as a ref to the <Button>
    • In the handleMenu callback, set the focus to the button when menuOpen is false.
      • menuButtonRef.current?.focus();
        const handleMenu = useCallback( () => {
        if ( ! menuOpen ) {
        trackEvent( `${ viewContext }_headerbar`, 'open_usermenu' );
        }
        setMenuOpen( ! menuOpen );
        }, [ menuOpen, viewContext ] );

Test Coverage

QA Brief

  • Visit the Google Site Kit dashboard from within the WordPress admin dashboard.
  • Using keyboard navigation, tab until focus is set on the user menu.
  • Enter the user menu (i.e via pressing Space or Enter).
  • Navigate the user menu with the arrow keys (optional).
  • Exit the user menu via the Escape key.
  • Note that the user menu element should remain in focus.
  • Validate that you can enter the user menu yet again (i.e via pressing Space or Enter).
  • Exit the user menu once more, focus should remain on the user menu icon.
  • Continue to tab to other elements.
  • Validate that focus unsets/is no longer set on the user menu.

The below GIF indicates what a successfully functioning version of the above may look like:

Screen Recording 2023-05-28 at 11 08 51 PM

Changelog entry

  • Ensure focus remains on user menu button when the menu is exited with the keyboard.
@tofumatt tofumatt added Type: Bug Something isn't working P1 Medium priority labels Feb 23, 2023
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Feb 23, 2023
@derweili derweili self-assigned this Apr 12, 2023
@derweili derweili removed their assignment Apr 12, 2023
@eugene-manuilov eugene-manuilov self-assigned this Apr 18, 2023
@eugene-manuilov
Copy link
Collaborator

IB ✔️

@eugene-manuilov eugene-manuilov removed their assignment Apr 18, 2023
@tofumatt tofumatt added the Good First Issue Good first issue for new engineers label May 19, 2023
@10upsimon 10upsimon self-assigned this May 26, 2023
@10upsimon 10upsimon assigned 10upsimon and unassigned 10upsimon May 28, 2023
@10upsimon 10upsimon assigned tofumatt and unassigned 10upsimon Jun 2, 2023
@tofumatt tofumatt removed their assignment Jun 2, 2023
@mohitwp mohitwp self-assigned this Jun 6, 2023
@mohitwp
Copy link
Collaborator

mohitwp commented Jun 7, 2023

QA Update ✅

  • Tested on dev environment.
  • Verified that the Account Menu button next to the help button is remained focused (including being visibly focused with a visible focus state) when the user exits the Account dropdown menu, using the “Escape” key to close the menu.
Recording.395.mp4

@mohitwp mohitwp removed their assignment Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Exp: SP Good First Issue Good first issue for new engineers P1 Medium priority Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants