material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[autocomplete] In the multiple+checkbox demo the popup's scroll position jumps to top after selection

Open PeterTaankvist opened this issue 1 year ago • 9 comments

Steps to reproduce

Steps:

  1. Open this link: https://mui.com/material-ui/react-autocomplete/#checkboxes
  2. Open autocomplete and scroll the popup until the scroll position is not at the top
  3. Now select an item
  4. 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

PeterTaankvist avatar Nov 06 '25 13:11 PeterTaankvist

Now select an item while being scrolled down

Why you want to select an item while also scrolling down? And how to do this?

ZeeshanTamboli avatar Nov 08 '25 05:11 ZeeshanTamboli

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 :)

PeterTaankvist avatar Nov 10 '25 06:11 PeterTaankvist

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)

mj12albert avatar Nov 10 '25 06:11 mj12albert

I mean just scroll down to the button

Sorry, I didn't understand. Which button?

ZeeshanTamboli avatar Nov 10 '25 09:11 ZeeshanTamboli

I've updated the repro steps in the issue description @ZeeshanTamboli

mj12albert avatar Nov 10 '25 10:11 mj12albert

@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 avatar Nov 10 '25 12:11 ZeeshanTamboli

@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.

PeterTaankvist avatar Nov 10 '25 13:11 PeterTaankvist

@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.

ZeeshanTamboli avatar Nov 10 '25 13:11 ZeeshanTamboli

I tried to attach another video showing it

https://github.com/user-attachments/assets/46280bce-7576-4170-a5e5-7432f248c929

PeterTaankvist avatar Nov 10 '25 13:11 PeterTaankvist

It also seems that it is important that the selection is empty beforehand

PeterTaankvist avatar Nov 10 '25 14:11 PeterTaankvist

@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 avatar Nov 10 '25 14:11 ZeeshanTamboli

@ZeeshanTamboli It does indeed seem like it has something to do with the focus remaining

PeterTaankvist avatar Nov 11 '25 06:11 PeterTaankvist

@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.

ZeeshanTamboli avatar Nov 11 '25 13:11 ZeeshanTamboli

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.

ZeeshanTamboli avatar Nov 12 '25 07:11 ZeeshanTamboli

Hi maintainers 👋 I’d like to work on this issue. Please let me know if it’s already assigned to someone. Thanks!

hrishikesh2810 avatar Jan 12 '26 05:01 hrishikesh2810

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.

github-actions[bot] avatar Feb 11 '26 14:02 github-actions[bot]