mui / mui/material-ui

autoFocus on menuItem doesn't focus on menu open via click

Open
#36,535 5 comments 1 reaction 1 assignee View on GitHub

@mnajdova is already working on this.

Since Mar 16, 2023.

scope: menu
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/blissful-kare-sokg13?file=/demo.tsx

Steps:

  1. Click dashboard button
  2. First menu item should be focused
Current behavior 😯

First menu item is focused (see console), but focus styling and class is not applied.

Expected behavior 🤔

First menu item has focus styling and class applied

Context 🔦

I'm trying show the user which menu item is focussed on menu open.

This may change based on which item I have applied autoFocus to

If you click and drag on the button, but do not click on it directly, and then press enter it does focus as expected.

Your environment 🌎
npx @mui/envinfo
 System:
    OS: macOS 12.2.1
  Binaries:
    Node: 19.6.0 - ~/.volta/tools/image/node/19.6.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 9.4.0 - ~/.volta/tools/image/node/19.6.0/bin/npm
  Browsers:
    Chrome: 111.0.5563.64
    Edge: Not Found
    Firefox: 110.0.1
    Safari: 15.3
  npmPackages:
    @emotion/react: ^11.10.6 => 11.10.6 
    @emotion/styled: ^11.10.6 => 11.10.6 
    @mui/base:  5.0.0-alpha.121 
    @mui/core-downloads-tracker:  5.11.13 
    @mui/icons-material: ^5.11.11 => 5.11.11 
    @mui/material: ^5.11.13 => 5.11.13 
    @mui/private-theming:  5.11.13 
    @mui/styled-engine:  5.11.11 
    @mui/system:  5.11.13 
    @mui/types:  7.2.3 
    @mui/utils:  5.11.13 
    @types/react: ^18.0.28 => 18.0.28 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    typescript: ^5.0.1-rc => 5.0.1-rc 

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.