Skip to content

fix(recycling): place item separator correctly in inverted lists - #2441

Open
HoshangDEV wants to merge 1 commit into
Shopify:mainfrom
HoshangDEV:fix/inverted-item-separator-placement
Open

fix(recycling): place item separator correctly in inverted lists#2441
HoshangDEV wants to merge 1 commit into
Shopify:mainfrom
HoshangDEV:fix/inverted-item-separator-placement

Conversation

@HoshangDEV

@HoshangDEV HoshangDEV commented Aug 14, 2026

Copy link
Copy Markdown

Description

In an inverted list, ItemSeparatorComponent lands on the wrong side of the item: every separator shifts one slot toward the start, the last two items sit flush against each other, and a stray separator dangles off the start edge.

inverted applies a flip transform to both the scroller (useSecondaryProps) and each cell (ViewHolder), so the two cancel inside the cell but the cells themselves are mirrored — a cell's trailing edge points at index − 1, not index + 1. The fix is placement only: render the separator ahead of the item when inverted. leadingItem/trailingItem semantics, the last-row suppression in ViewHolderCollection, and measured cell size are all unchanged.

Related to #638, which reported this against 1.3.0 and still reproduces on 2.3.2.

Reviewers' hat-rack 🎩

  • The double-flip reasoning in ViewHolder.tsx is the whole basis of the fix — worth confirming independently.
  • Grid and masonry (numColumns > 1) should follow the same argument, but have no dedicated coverage in this PR.

Screenshots or videos (if needed)

InvertedTest on the iOS simulator (iPhone 17, iOS 26.5). The fixture screen was temporarily tweaked to make the effect legible — separator 12px red instead of 1px grey, and 5 items so both ends of the list fit on screen. Those tweaks are not part of this PR.

Before After

Before: Item 4 and Item 3 are flush with no separator between them, and a stray separator sits below Item 0 against the header. After: a separator between all four adjacent pairs, and both outer edges clean.

Test plan

  • yarn test (189 passed, 15 suites), yarn type-check, yarn lint
  • New src/__tests__/InvertedSeparator.test.tsx asserts separator-vs-item order per cell in both directions, and was confirmed to fail on unmodified main for the inverted case
  • Verified on iOS simulator — before/after above
  • Android emulator — not run

In an inverted list both the scroller and each cell carry a flip transform, so
a cell's trailing separator visually lands between items i and i-1. Every
separator shifts one slot toward the start of the list, the two items at the
far end sit flush against each other, and a stray separator dangles off the
start edge.

Render the separator ahead of the item when inverted so it still falls between
items i and i+1.

Related to Shopify#638
@HoshangDEV

Copy link
Copy Markdown
Author

I have signed the CLA!

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.

1 participant