-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Autocomplete] Fix list scrolls to the top when new data is added on touch devices #36231
[Autocomplete] Fix list scrolls to the top when new data is added on touch devices #36231
Conversation
Netlify deploy previewhttps://deploy-preview-36231--material-ui.netlify.app/ Bundle size report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the preview package CodeSandbox of this PR, the scrollbar is still resetting in mobile view - https://codesandbox.io/s/mui-autocomplete-after-silyqj
@ZeeshanTamboli Thanks, I just updated the dependencies, you can check the same link. |
@SaidMarar I am still not able to see it fixed in https://codesandbox.io/s/mui-autocomplete-after-silyqj. |
@ZeeshanTamboli Did you tested it in mobile simulator using the touch pointer to scroll ? If yes, are you observing the same behavior of resting scroll to the top ? |
I didn't test in mobile simulator but in desktop browser in mobile view and saw it's still resetting. It has the touch pointer. |
@ZeeshanTamboli I tested it in both, could you please check the video. I can make another for browser, if i get some time. Upload.from.GitHub.for.iOS.MOV |
Okay, I checked on mobile instead and it works. I don't know why it didn't work in mobile device mode in desktop browser: Screen.Recording.-.1.March.2023.mp4 |
Ah I see ! It is because you are using the wheel to scroll and it is not the case in mobile, you need to scroll using the touch pointer. (this is the fix we did we save the option on touchStart in mobile. For desktop we already have mouseOver) |
@ZeeshanTamboli just updated, thank you for reviewing this 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
closes: #36212
The reason it is working on desktop is because when we mouseover an option we update highlightedIndex in handleOptionMouseOver , However, on mobile, the index is not updated when we touch the option, which results in the index remaining at -1 and causing the list to scroll to the top
before: https://codesandbox.io/s/mui-autocomplete-before-tmnvsm
after: https://codesandbox.io/s/mui-autocomplete-after-q32885