mui / mui/material-ui

[material-ui][Autocomplete] Shouldn't close popper if disableCloseOnSelect and the click is within the popper/paper

Open
#40,966 5 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

scope: autocomplete type: new feature waiting for 👍
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/p/sandbox/autocomplete-dontcloseonselect-hlj9mp

Steps:

  1. Open dropdown
  2. Click outside of the ul but within the Popper or within the Paper.
Current behavior

The popper closes.

Expected behavior

The popper shouldn't close.

Context

Check this real life example: https://codesandbox.io/p/sandbox/autocomplete-multiple-popper-7w9tn6?file=%2Fsrc%2FAutocompleteMultiCustom.tsx%3A23%2C11-23%2C31

Not closing on Paper/Popper click would allow to easily implement things like SelectAll / DeselectAll and other stuff. In this example clicking on Select All closes the popper and doesn't even trigger SelectAll button click.

I'm not clear how the disableCloseOnSelect is implemented, but seems that it does not close the popper when the click is within the ul element. Because even though I customize ListboxComponent it still closes the popper.

(Alternatively another props can be added: disableCloseOnClickWithinPopper, disableCloseOnClickWithinPaper)

Your environment

No response

Search keywords: autocomplete disableCloseOnSelect popper close

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.

Research direction

Start with the Autocomplete component's popper, paper, and listbox click-handling paths, using the linked CodeSandbox to reproduce the behavior. Done means clicks within the Popper or Paper do not close the popper when disableCloseOnSelect is enabled, while the existing listbox behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.