Skip to content

Conversation

@SyedAbdulAzeemSF4852
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • On iOS and Android, when IsEnabled is set to false on CollectionView or CarouselView, users can still interact with the control, including swiping through items and scrolling. This behavior is inconsistent with Windows, where setting IsEnabled = false correctly blocks all user interactions.

Root Cause

Android

  • CollectionView : MauiRecyclerView (used by CollectionView) was not checking the Enabled property inside OnInterceptTouchEvent, which allowed touch events to continue propagating. As a result, swipe and scroll gestures still worked even when the control was disabled.

  • CarouselView : MauiCarouselRecyclerView already included an IsSwipeEnabled check in OnInterceptTouchEvent, but it did not check the Enabled state either, which prevented it from fully blocking interaction when IsEnabled was set to false.

iOS

  • UICollectionView (the native control backing CollectionView and CarouselView) doesn't inherit from UIControl and doesn't automatically disable user interaction when IsEnabled is set to false. Unlike other iOS controls, UICollectionView requires explicitly setting the UserInteractionEnabled property to false to block touch events.

Description of Change

  • Android: Updated the OnInterceptTouchEvent method in both MauiCarouselRecyclerView and MauiRecyclerView to return false when the view is disabled, preventing touch interactions when IsEnabled is false.
  • iOS: Added mapping for the IsEnabled property in handlers (CarouselViewHandler, ItemsViewHandler, and their v2 counterparts) and implemented the UpdateIsEnabled extension for UICollectionView, which sets UserInteractionEnabled based on the view's enabled state.

Issues Fixed

Fixes #32791

Validated the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Platform Before After
Android
Android_Before.mov
Android_After.mov
iOS
iOS_Before.mov
iOS_After.mov

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

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 21, 2025
@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 force-pushed the fix-carouselview-swiping-when-disabled branch from 5f2aa59 to aaffcbf Compare November 21, 2025 11:10
@sheiksyedm sheiksyedm marked this pull request as ready for review November 21, 2025 14:34
Copilot AI review requested due to automatic review settings November 21, 2025 14:34
@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copilot finished reviewing on behalf of sheiksyedm November 21, 2025 14:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where CollectionView and CarouselView remain interactive when IsEnabled is set to false on iOS and Android platforms. The fix ensures these controls properly block user interactions (scrolling, swiping) when disabled, matching Windows behavior.

Key changes:

  • Android: Added Enabled property checks in OnInterceptTouchEvent methods to prevent touch event propagation when controls are disabled
  • iOS: Implemented UpdateIsEnabled extension method that sets UserInteractionEnabled on UICollectionView, with proper handler mappings for both v1 and v2 handlers
  • Tests: Added UI test case verifying CarouselView respects IsEnabled property

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Core/src/Platform/iOS/CollectionViewExtensions.cs Adds UpdateIsEnabled extension method for UICollectionView to sync UserInteractionEnabled with IsEnabled property
src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs Overrides OnInterceptTouchEvent to return false when disabled, blocking touch interactions
src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs Adds Enabled check to existing swipe-enabled logic in OnInterceptTouchEvent
src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs Adds MapIsEnabled static method to call UpdateIsEnabled extension
src/Controls/src/Core/Handlers/Items/ItemsViewHandler.cs Registers IsEnabled property mapping for iOS/MacCatalyst platforms
src/Controls/src/Core/Handlers/Items/CarouselViewHandler.iOS.cs Adds MapIsEnabled method for CarouselView handler
src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs Registers IsEnabled property mapping for iOS/MacCatalyst
src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.iOS.cs Adds MapIsEnabled to v2 handler implementation
src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs Adds MapIsEnabled to v2 CarouselView handler
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Documents new public override for OnInterceptTouchEvent
src/Controls/tests/TestCases.HostApp/Issues/Issue32791.cs Test page demonstrating disabled CarouselView behavior
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32791.cs UI test validating CarouselView cannot be swiped when disabled

Comment on lines +22 to +27
#if MACCATALYST
// MacCatalyst: Wait for item transition to complete after scroll gesture
Thread.Sleep(1000);
#endif
var statusText = App.WaitForElement("Issue32791StatusLabel").GetText();
Assert.That(statusText, Is.EqualTo("Success"));
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

Platform-conditional compilation with Thread.Sleep in the test can hide test failures on MacCatalyst. If the sleep is truly necessary for MacCatalyst, consider documenting why, or better yet, use a proper wait mechanism.

According to the UI testing guidelines, tests should use App.WaitForElement or similar explicit waits rather than arbitrary sleeps. If there's a specific element state you're waiting for on MacCatalyst, wait for that explicitly.

Suggested change
#if MACCATALYST
// MacCatalyst: Wait for item transition to complete after scroll gesture
Thread.Sleep(1000);
#endif
var statusText = App.WaitForElement("Issue32791StatusLabel").GetText();
Assert.That(statusText, Is.EqualTo("Success"));
// Wait for the status label to display "Success" after scroll gesture
App.WaitFor(() =>
{
var label = App.FindElement("Issue32791StatusLabel");
return label != null && label.GetText() == "Success";
}, timeout: TimeSpan.FromSeconds(5));
var statusText = App.FindElement("Issue32791StatusLabel").GetText();
Assert.That(statusText, Is.EqualTo("Success"));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android, iOS] CollectionView and CarouselView remain interactive when disabled

3 participants