Skip to content

Add layout-aware drop targeting for custom layouts#605

Merged
gabreho merged 1 commit intosquare:mainfrom
gabreho:gabrielh/active-moving-item-tracking
Feb 10, 2026
Merged

Add layout-aware drop targeting for custom layouts#605
gabreho merged 1 commit intosquare:mainfrom
gabreho:gabrielh/active-moving-item-tracking

Conversation

@gabreho
Copy link
Collaborator

@gabreho gabreho commented Feb 10, 2026

Describe your changes here. Please include screenshots if they're visual!

This change allows custom ListLayout implementations to override
drop target determination during interactive item reordering.

  • Add targetIndexPath(forInteractivelyMovingItem:withPosition:) protocol method to ListLayout with default nil implementation
  • Add CollectionViewLayout override that delegates to custom layout
  • Add isReorderable property on ListLayoutContent.ItemInfo to expose whether an item has reordering enabled

Checklist

Please do the following before merging:

  • Ensure any public-facing changes are reflected in the changelog. Include them in the Main section.

  This change allows custom ListLayout implementations to override
  drop target determination during interactive item reordering.

  - Add targetIndexPath(forInteractivelyMovingItem:withPosition:) protocol
    method to ListLayout with default nil implementation
  - Add CollectionViewLayout override that delegates to custom layout
  - Add isReorderable property on ListLayoutContent.ItemInfo to expose
    whether an item has reordering enabled
Comment on lines -626 to -628
/// TODO: The default implementation provided by `UICollectionView` does not work correctly
/// when trying to move an item to the end of a section, or when trying to move an item into an
/// empty section. We should add casing that allows moving into the section in these cases.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do we need to keep this TODO?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's still true, it doesn't hurt to keep it, IMO (but then also, the TODO has been here forever, so I don't care either way)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay either way. I lean towards removing since we don't have a good repro on file. I did some local testing and haven't run across these reordering issues on iOS 16 or iOS 26, so the issue may be fixed!

Copy link
Contributor

@johnnewman-square johnnewman-square left a comment

Choose a reason for hiding this comment

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

This looks great. It would be neat if we could spin up a demo controller for the sample app that showcases the new targetIndexPath(...) API.

Comment on lines -626 to -628
/// TODO: The default implementation provided by `UICollectionView` does not work correctly
/// when trying to move an item to the end of a section, or when trying to move an item into an
/// empty section. We should add casing that allows moving into the section in these cases.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay either way. I lean towards removing since we don't have a good repro on file. I did some local testing and haven't run across these reordering issues on iOS 16 or iOS 26, so the issue may be fixed!

@gabreho gabreho merged commit be21499 into square:main Feb 10, 2026
3 checks passed
johnnewman-square added a commit that referenced this pull request Feb 10, 2026
## What's Changed
* Add layout-aware drop targeting for custom layouts by @gabreho in
#605


### Checklist

Please do the following before merging:

- [x] Ensure any public-facing changes are reflected in the
[changelog](https://github.com/square/Listable/blob/main/CHANGELOG.md).
Include them in the `Main` section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants