Skip to content

[Autocomplete] openOnFocus reopens popup when window regains focus and can trigger unintended option selection #47661

@pcourant

Description

@pcourant

Steps to reproduce

To reproduce : https://mui.com/material-ui/react-autocomplete/#playground => variante openOnFocus

Steps:

  1. Open the Autocomplete input (openOnFocus=true) by clicking into the input so the popup is visible.
  2. Switch to a different window (e.g. click another application / another browser window) so the current window loses focus.
  3. Return to the original window by clicking in the area where the popup options were displayed (i.e. where an option would be under the pointer).
  4. Observe that the popup reopens on focus regain and the click can select the option under the pointer (worst case).

Image

Current behavior

When the window regains focus via a click, Autocomplete reopens the popup due to openOnFocus.
Because the popup is rendered immediately under the pointer, the same click can end up selecting an option (worst case) or reopening the popup unexpectedly.

This is especially problematic when the popup overlaps other UI controls (e.g. a Save button): the user's click intended to interact with the underlying UI is intercepted by the reopened popup and may change the selection.

Expected behavior

Regaining window focus via click should not cause the popup to reopen.

Context

No response

Your environment

npx @mui/envinfo Browser : Chrome et Edge System: OS: Linux 5.0 undefined Binaries: Node: 20.19.1 - /usr/local/bin/node npm: 10.8.2 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm Browsers: Chrome: Not Found Firefox: Not Found npmPackages: @emotion/react: latest => 11.14.0 @emotion/styled: latest => 11.14.1 @mui/core-downloads-tracker: 7.3.7 @mui/material: latest => 7.3.7 @mui/private-theming: 7.3.7 @mui/styled-engine: 7.3.7 @mui/system: 7.3.7 @mui/types: 7.4.10 @mui/utils: 7.3.7 @types/react: latest => 19.2.9 react: latest => 19.2.3 react-dom: latest => 19.2.3 typescript: latest => 5.9.3

Search keywords: Autocomplete openOnFocus window focus blur click unintended selection popper

Metadata

Metadata

Assignees

Labels

scope: autocompleteChanges related to the autocomplete. This includes ComboBox.type: bugIt doesn't behave as expected.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions