[autocomplete] In the multiple+checkbox demo the popup's scroll position jumps to top after selection
Steps to reproduce
Steps:
- Open this link: https://mui.com/material-ui/react-autocomplete/#checkboxes
- Open autocomplete and scroll the popup until the scroll position is not at the top
- Now select an item
- The scroll position jumps back up to the top
https://github.com/user-attachments/assets/5e688fbf-3849-4cfa-a37a-9c63bed7ec78
Current behavior
The scrollbar jumps
Expected behavior
I expect it not to jump
Context
No response
Your environment
I used chrome
Search keywords: Autocomplete Scrollbar Jump
Now select an item while being scrolled down
Why you want to select an item while also scrolling down? And how to do this?
Now select an item while being scrolled down
Why you want to select an item while also scrolling down? And how to do this?
I mean just scroll down to the button, then select an item e.g. the lowest one. Then it will jump to the top :)
With a normal multi-autocomplete + disableCloseOnSelect it works properly, the scroll position doesn't jump after you select something: https://stackblitz.com/edit/h6i4uehm-asftem6q?file=src%2FDemo.tsx
So I suspect it's an issue with the checkbox demo itself
(BTW testing the checkbox demo on iPhone seems to work correctly, the scroll position of the popup doesn't change when I pick an item)
I mean just scroll down to the button
Sorry, I didn't understand. Which button?
I've updated the repro steps in the issue description @ZeeshanTamboli
@mj12albert @PeterTaankvist I am not able to reproduce it on Windows OS. See the following screen recording:
https://github.com/user-attachments/assets/9a1e8490-1c52-4b58-a0c6-fbbc157f5c19
@ZeeshanTamboli It only happens for me if I open the dropdown, close it, then open it again and only then I scroll down to the bottom and select a value.
@ZeeshanTamboli It only happens for me if I open the dropdown, close it, then open it again and only then I scroll down to the bottom and select a value.
It doesn't happen for me.
I tried to attach another video showing it
https://github.com/user-attachments/assets/46280bce-7576-4170-a5e5-7432f248c929
It also seems that it is important that the selection is empty beforehand
@PeterTaankvist Thanks for the video reproduction. I can reproduce when we click on the Autocomplete input to close it and then reopen it. When I click outside of the autocomplete it isn't reproducible:
https://github.com/user-attachments/assets/8c6913cd-bbba-4886-affc-55ecae5d788d
@ZeeshanTamboli It does indeed seem like it has something to do with the focus remaining
@ZeeshanTamboli It does indeed seem like it has something to do with the focus remaining
Might be. Even in the normal reproduction (without checkbox) provided by @mj12albert here the scroll jumps to the top if we click on the Autocomplete input to re-open it. So looks like a general issue on Autocomplete.
It's a regression from #46894 which was released in v7.3.3.
Working in v7.3.2: https://stackblitz.com/edit/h6i4uehm-ncqdckmc?file=src%2FDemo.tsx
Broke in v7.3.3: https://stackblitz.com/edit/h6i4uehm-wpzadqst?file=src%2FDemo.tsx
This issue is noticeable only when disableCloseOnSelect prop is enabled.
Hi maintainers 👋 I’d like to work on this issue. Please let me know if it’s already assigned to someone. Thanks!
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.
@PeterTaankvist Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.