mui / mui/material-ui

Select onFocus called way too many times

Open
#44,505 3 comments 2 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

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

Description

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/p/sandbox/q649qz
  2. Open console to see logs
  3. Click into the select box
  4. Click off the select box
  5. Click off the select box again
Current behavior

On the initial focus, onFocus is called 4 times. On initial blur, onFocus is called 2 more times and onBlur is not called. On second blur, onBlur is called.

Expected behavior

On initial focus, onFocus should be called once and not again until component is blurred and refocused. onBlur should be called when input is initially blurred.

Context

I have a code associated to with onFocus event that is being called 4 times when I expect it to be called once.

Your environment
npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: mui select onfocus multiple times

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.