Skip to content

fix: Flex items not moved next to fixed items and after a line change - #660

Draft
MatiPl01 wants to merge 2 commits into
fix/flex-reorder-strategyfrom
fix/flex-reorder-fixed-items
Draft

MatiPl01 wants to merge 2 commits into
fix/flex-reorder-strategyfrom
fix/flex-reorder-fixed-items

Conversation

@MatiPl01

Copy link
Copy Markdown
Owner

Description

Follow-up to #655 (stacked on it): drags in Sortable.Flex that left the dragged item where it was although there was a valid place for it under the pointer:

  • an item whose target slot was taken by a fixed-order item was not moved at all, so it could not be dragged to a line that ends with a fixed item while the pointer was over or past that item, or when only fixed items followed its slot there. It now takes the closest free slot,
  • when taking the dragged item out of its line lets the next item join the previous line, the layout has one line less than the strategy expected. The item could not be moved down, and with fixed items the order could flip back and forth with the pointer at rest,
  • an item wider than the container could not be moved to a previous line.

Known limitation: with gaps, an item can only be moved one line up through the start of the list when the line above has room for it without the gap (two order changes instead of one, same as on main).

Testing

13 jest tests in index.test.tsx, 9 fail on the base branch. Randomized drags, the same inputs on this branch, its base and main: no flipping at rest and no broken order on this branch, and the dragged item ends closer to the pointer than on the base in 4 to 5.5% of the drags and farther in 0.01 to 0.08%.

Not checked on a device.

Evidence
Tests on the base branch before-test-on-base-branch.txt
Tests with the fix after-test-with-fix.txt
Randomized drags, this branch vs its base vs main fuzz-results.txt

- an item whose walk along a line ended on a fixed item was not moved at all, it now takes the closest free slot
- an item could not move to the last line when only fixed items followed its slot there
- the place of the active item in its line is read from the layout, which can have one line less than expected once the item is taken out
- an item wider than the container can be moved to a previous line, where it starts a line as in the layout
The expected line is one too far when the item that takes the place of the dragged one joins the previous line. The bounds of the next move were then taken from a line that does not exist, and the order could flip back and forth with the pointer at rest.
@vercel

vercel Bot commented Nov 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
react-native-sortables-docs Ignored Ignored Nov 26, 2026 4:22pm UTC

@MatiPl01 MatiPl01 self-assigned this Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant