dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

CollectionView ScrollTo scrolls to wrong group index in Android #22915

Open G0A75 opened 3 months ago

G0A75 commented 3 months ago

Description

The Android ScrollTo seems to always scroll to the first group index

https://github.com/dotnet/maui/assets/8534279/274dfdfe-e4eb-45da-b8ef-9b5b0a7800dc

This is what is looks like on IOS

https://github.com/dotnet/maui/assets/8534279/0284fc11-066e-49c2-a448-255a3f021dcb

Steps to Reproduce

  1. Create new MAUI project
  2. Add Grid with 3 buttons and a CollectionView
  3. Add the button_clicked event handler to buttons
  4. in the event handler check the button text in a switch statement and use the CollectionView.ScrollTo method to scroll to each the first item and the group index(button1 scrolls to group index 0, button 2 to group index 2, ...) Expected outcome: Each button scrolls to its associated group Actual outcome: Each button scrolls to the first group index.

Link to public reproduction project repository

https://github.com/G0A75/CollectionViewScroll

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/scrolling?view=net-maui-8.0#scroll-an-item-into-view

you can pass an item and group object to the ScrollTo method which works and scrolls to the proper group

Relevant log output

No response

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ninachen03 commented 3 months ago

Verified this issue with Visual Studio 17.11.0 Preview 2 (8.0.40 & 8.0.21 & 8.0.3). Can repro it.

voverchuk-devsx commented 3 months ago

Also verified in 8.0.60, Android 14 I also tried with grid items, did not help Always scroll to the first group