mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.83k stars 32.26k forks source link

[material-ui][Autocomplete] Scroll resets upon selection that has multiple, disableCloseOnSelect and filterSelectedOptions passed as true #39202

Open KartheekJavvaji opened 1 year ago

KartheekJavvaji commented 1 year ago

Duplicates

Latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/mui-scroll-reset-issue-cpvj7v?file=/Demo.tsx

Steps:

  1. Have an autocomplete which has multiple, disableCloseOnSelect and filterSelectedOptions set to true
  2. Scroll down and select any one of the options
  3. We can observe that the scroll resets back to top

https://github.com/mui/material-ui/assets/12635717/e06eef9d-e686-4052-b15c-bd74ca75cf63

Current behavior 😯

The scroll gets reset after any selection with above mentioned 3 properties sent as true.

Expected behavior 🤔

The scroll should not get reset as in case of a long list this will be difficult for the end-user to select multiple options.

It will be helpful if we control this behavior either by introducing a new prop or by reusing filterSelectedOptions boolean near the place where highlighting of the option happens.

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```
nandini584 commented 1 year ago

Can this issue be assigned to me, I am interested in working here...

KartheekJavvaji commented 1 year ago

@nandini584 I have already raised a PR for fixing this issue. You can take a look at it for initial analysis.

KartheekJavvaji commented 1 year ago

I am still waiting for @mj12albert for his review on the strategy used in the fix.

nandini584 commented 1 year ago

Ohk sure will have a look.