Skip to content

[iOS, Mac] Fix for CollectionView not triggering Scrolled event when grouped and groups are empty#30375

Closed
SyedAbdulAzeemSF4852 wants to merge 2 commits intodotnet:mainfrom
SyedAbdulAzeemSF4852:fix-30249
Closed

[iOS, Mac] Fix for CollectionView not triggering Scrolled event when grouped and groups are empty#30375
SyedAbdulAzeemSF4852 wants to merge 2 commits intodotnet:mainfrom
SyedAbdulAzeemSF4852:fix-30249

Conversation

@SyedAbdulAzeemSF4852
Copy link
Copy Markdown
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

  • Grouped CollectionView not triggering the Scrolled event for empty groups on iOS.

Root Cause

  • The Scrolled method in ItemsViewDelegator and ItemsViewDelegator2 contains an early return that prevents the Scrolled event from firing when there are no visible items. This behavior unintentionally skips scroll notifications for empty groups.

Description of Change

  • Modified the Scrolled method in ItemsViewDelegator and ItemsViewDelegator2 to check for headers or footers before returning early when no visible items are present.
  • Added a new helper method HasHeaderOrFooter to determine if headers or footers exist, including structured and group headers/footers.

Issues Fixed

Fixes #30249

Validated the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Before After
Before.mov
After.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 2, 2025
@dotnet-policy-service
Copy link
Copy Markdown
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 Jul 2, 2025
@jsuarezruiz jsuarezruiz added platform/macos macOS / Mac Catalyst platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Jul 2, 2025
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 marked this pull request as ready for review July 2, 2025 12:42
Copilot AI review requested due to automatic review settings July 2, 2025 12:42
@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 requested a review from a team as a code owner July 2, 2025 12:42
Copy link
Copy Markdown
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 ensures that grouped CollectionView instances with empty groups on iOS and Mac still trigger the Scrolled event by checking for headers/footers before early-returning, and adds end-to-end UI tests to validate the fix.

  • Updated Scrolled implementations to include a header/footer presence check.
  • Introduced a HasHeaderOrFooter helper method in both ItemsViewDelegator and ItemsViewDelegator2.
  • Added a host app scenario and a shared UI test to verify scrolling on grouped empty collections.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Controls/src/Core/Handlers/Items/iOS/ItemsViewDelegator.cs Modified Scrolled early-return condition and added HasHeaderOrFooter helper
src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewDelegator2.cs Applied the same Scrolled update and helper in the Items2 delegator
src/Controls/tests/TestCases.HostApp/Issues/Issue30249.cs Introduced a test page with a grouped CollectionView and AutomationIds for UI interaction
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30249.cs Added a UI test that waits for the collection, scrolls, and asserts the Scrolled event flag

return (VisibleItems, firstVisibleItemIndex, centerItemIndex, lastVisibleItemIndex);
}

bool HasHeaderOrFooter()
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

This helper method is duplicated in ItemsViewDelegator2; consider extracting it into a shared base class or utility to avoid code duplication.

Copilot uses AI. Check for mistakes.
return (VisibleItems, firstVisibleItemIndex, centerItemIndex, lastVisibleItemIndex);
}

bool HasHeaderOrFooter()
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

Duplicate logic from the other delegator; extracting this into a common helper would improve maintainability.

Copilot uses AI. Check for mistakes.
{
App.WaitForElement("CollectionViewWithEmptyGroups");
App.ScrollDown("CollectionViewWithEmptyGroups", ScrollStrategy.Gesture, 0.2, 500);

Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using App.WaitForElement("ScrolledEventStatusLabel") before accessing its text to reduce test flakiness on slower devices or CI environments.

Suggested change
App.WaitForElement("ScrolledEventStatusLabel");

Copilot uses AI. Check for mistakes.

scrolledEventStatusLabel = new Label
{
AutomationId = "ScrolledEventStatusLabel",
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

Ensure these AutomationIds are unique across the host app to prevent conflicts when calling WaitForElement in shared tests.

Copilot uses AI. Check for mistakes.
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 21, 2026

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

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

Could you please resolve conflicts?

@SyedAbdulAzeemSF4852
Copy link
Copy Markdown
Contributor Author

Closing this PR since the issue has already been resolved on the main branch. PR #34153 removed the early if (!visibleItems) return; exit from the Scrolled method, ensuring the event is always fired and effectively fixing the bug.

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/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grouped CollectionView not triggering Scrolled-Event for empty groups on iOS

7 participants