oxidecomputer / oxidecomputer/console

Focus behavior on dropdown menu close

Open
#1,405 1 comment 0 reactions 1 assignee View on GitHub

@benjaminleonard is already working on this.

Since Mar 15, 2023.

a11y polish
Dominant language
TypeScript
Stars
228
Forks
22
Avg merge
19h 42m
Merged PRs (30d)
32

Description

Not sure we have to do anything. We might be fine with the current behavior. I think this was handled with :focus and :focus-visible before (see #1059 and https://github.com/oxidecomputer/console/pull/1201/commits/239d02fb3a98edb025df8ca266ff7f84ffdf63a6), but Radix must do something different from Reach in this regard.

As noted in https://github.com/oxidecomputer/console/pull/1395#discussion_r1136048710, we currently have a choice between two mediocre options. With onCloseAutoFocus set to prevent default as we are currently doing, we don't get an unwanted focus ring, but we also reset focus altogether so if you hit tab, you start over at the top of the page. Maybe that's fine.

https://github.com/oxidecomputer/console/blob/38ba2d018e3259387bc26f2b5c39d8ec0ac16e56/libs/ui/lib/dropdown-menu/DropdownMenu.tsx#L17-L25

If we don't set onCloseAutoFocus, we get the following behavior: the button is focused after you click out, and it gets a focus ring that I think we don't want (setting aside the bad rendering due to it being in a table cell — we could probably fix that). That behavior is shown below.

2023-03-14-radix-menu-focus-bug

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.