Skip to content
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

Fixed [iOS] Fix CarouselViewRemoveAt so that it's passing on both CV1 and CV2 sets of handlers #25919

Merged
merged 7 commits into from
Dec 11, 2024

Conversation

NirmalKumarYuvaraj
Copy link
Contributor

Issue Details

When using CV1 handlers, removing the first item from the CarouselView during navigation doesn't work as expected. The removed item remains visible in the view until we manually scroll it. This functionality works correctly with CV2 handlers.

Root Cause

When the CarouselView is detached and then reattached to the window, it doesn't undergo the proper initialization process again. This happens because the InitialPositionSet flag remains true from its previous attachment.

Description of Change

Setting the InitialPositionSet flag to false during the detachment process resolves the issue.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #25776

Output

Before After
Before.mov
After.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Nov 18, 2024
Copy link
Contributor

Hey there @NirmalKumarYuvaraj! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Nov 18, 2024
@@ -446,7 +446,7 @@ void ScrollToPosition(int goToPosition, int carouselPosition, bool animate, bool

void SetPosition(int position)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could include an UITest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz The test case for this scenario is already present. I have updated it to use the default CarouselView instead of CarouselView2.

@NirmalKumarYuvaraj NirmalKumarYuvaraj marked this pull request as ready for review November 20, 2024 09:35
@NirmalKumarYuvaraj NirmalKumarYuvaraj requested a review from a team as a code owner November 20, 2024 09:35
@NirmalKumarYuvaraj NirmalKumarYuvaraj added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
@dotnet dotnet deleted a comment from azure-pipelines bot Dec 6, 2024
@dotnet dotnet deleted a comment from azure-pipelines bot Dec 6, 2024
@dotnet dotnet deleted a comment from azure-pipelines bot Dec 6, 2024
@dotnet dotnet deleted a comment from jsuarezruiz Dec 6, 2024
@rmarinho
Copy link
Member

rmarinho commented Dec 6, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

rmarinho
rmarinho previously approved these changes Dec 9, 2024
@rmarinho rmarinho added this to the .NET 9 SR3 milestone Dec 9, 2024
@rmarinho rmarinho self-assigned this Dec 9, 2024

carousel.ScrollTo(position, -1, Microsoft.Maui.Controls.ScrollToPosition.Center, false);
await Task.Delay(100).ContinueWith((t) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best approach ? Why 100? can we try the Collection.PerformBatchUpdates see if it helps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmarinho , I have used the similar approach used in CarouselViewController2.cs. Using Collection.PerformBatchUpdates causes the page with carousel view freeze. Please verify and let me know if you have any concerns.

@rmarinho rmarinho self-requested a review December 9, 2024 17:51
@PureWeen PureWeen dismissed rmarinho’s stale review December 9, 2024 17:55

Changes Requested

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PureWeen PureWeen requested a review from Copilot December 10, 2024 15:55

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (2)

src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs:555

  • [nitpick] The variable name 'positionCurrentItem' could be more descriptive. Consider renaming it to 'currentItemPosition'.
var positionCurrentItem = ItemsSource.GetIndexForItem(currentItem).Row;

src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs:226

  • Ensure that setting 'InitialPositionSet' to false during detachment does not introduce any race conditions. Verify that it is correctly handled in all scenarios.
InitialPositionSet = false;
@NirmalKumarYuvaraj
Copy link
Contributor Author

@rmarinho rmarinho requested a review from PureWeen December 11, 2024 09:32
@rmarinho rmarinho dismissed PureWeen’s stale review December 11, 2024 15:33

Tests are green

@rmarinho rmarinho merged commit eeaf57b into dotnet:main Dec 11, 2024
106 checks passed
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution fixed-in-net8.0-nightly This may be available in a nightly release! fixed-in-net9.0-nightly This may be available in a nightly release! partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[iOS] Fix CarouselViewRemoveAt so that it's passing on both CV1 and CV2 sets of handlers
5 participants