maui icon indicating copy to clipboard operation
maui copied to clipboard

Fix ScrollToPosition.Center behavior in ScrollView on iOS and MacCatalyst

Open devanathan-vaithiyanathan opened this issue 11 months ago • 25 comments

Issue Details

When scrolling a ScrollView using the ScrollToAsync method with the ScrollPosition.Center value, the item is incorrectly centered.

Root Cause

The scroll offset values allow items to scroll into a negative position, causing the item to be incorrectly centered.

Description of Change

We clamp the scroll offset values to ensure the item does not scroll into a negative position.

Issues Fixed

Fixes #26760 Fixes #28965

Validated the behaviour in the following platforms

  • [x] Android
  • [x] Windows
  • [x] iOS
  • [x] Mac

Output Screenshot

Before After

/azp run

Redth avatar Jan 02 '25 17:01 Redth

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jan 02 '25 17:01 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jan 10 '25 13:01 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jan 13 '25 09:01 azure-pipelines[bot]

/rebase

jsuarezruiz avatar Jan 31 '25 12:01 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Feb 10 '25 08:02 azure-pipelines[bot]

The test ScrollToElement3End fails with small changes on Mac and iOS: image

Could you review it and see if is related with the changes?

@jsuarezruiz, Yes, the test failure is related to my changes, and the snapshot has a slight difference. Shall I commit the newly generated image?

Shalini-Ashokan avatar Feb 13 '25 09:02 Shalini-Ashokan

/rebase

jsuarezruiz avatar Feb 26 '25 12:02 jsuarezruiz

The test ScrollToElement3End fails with small changes on Mac and iOS: image Could you review it and see if is related with the changes?

@jsuarezruiz, Yes, the test failure is related to my changes, and the snapshot has a slight difference. Shall I commit the newly generated image?

Yes, thanks in advance.

jsuarezruiz avatar Feb 26 '25 12:02 jsuarezruiz

/azp run

jsuarezruiz avatar Feb 27 '25 11:02 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Feb 27 '25 11:02 azure-pipelines[bot]

/rebase

rmarinho avatar Feb 27 '25 15:02 rmarinho

/azp run

rmarinho avatar Feb 27 '25 15:02 rmarinho

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Feb 27 '25 15:02 azure-pipelines[bot]

/rebase

jsuarezruiz avatar Mar 07 '25 07:03 jsuarezruiz

/azp run

jsuarezruiz avatar Mar 07 '25 10:03 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Mar 07 '25 10:03 azure-pipelines[bot]

/rebase

jsuarezruiz avatar Mar 25 '25 07:03 jsuarezruiz

/azp run

jsuarezruiz avatar Mar 27 '25 07:03 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Mar 27 '25 07:03 azure-pipelines[bot]

/azp run

jsuarezruiz avatar May 09 '25 12:05 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar May 09 '25 12:05 azure-pipelines[bot]

Fix conflict

@PureWeen, I have resolved the conflicts.

Shalini-Ashokan avatar May 12 '25 06:05 Shalini-Ashokan

/azp run MAUI-UITests-public

jsuarezruiz avatar May 16 '25 11:05 jsuarezruiz

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 16 '25 11:05 azure-pipelines[bot]

/rebase

jfversluis avatar Aug 27 '25 10:08 jfversluis

/azp run MAUI-UITests-public

jfversluis avatar Aug 27 '25 10:08 jfversluis

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Aug 27 '25 10:08 azure-pipelines[bot]