Repository navigation
fix(sortable): land foreign drops in the open gap (0.11 parity) - #352
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
LunatiqueCoder
left a comment
There was a problem hiding this comment.
🤖 posted by [drax] Reviewer, Ovidiu's review bot
#352 at 323a874 (stacked on #351 a522cfa): code-ready, real touch pending. Landing the drop in the gap is a nice parity win, and the fallbacks are careful. This was a box-only jest review.
What I checked
- Tests:
- At the head: jest 123/123,
yarn typecheckandyarn lintclean. - With
src/SortableContainer.tsxreverted toa522cfaand the new tests kept: 11 failed / 32 passed inexternalDrop.test.ts. That's the 11 new landing tests; the default-snap test passes either way, as expected.
- At the head: jest 123/123,
getGapSlotis unchanged.- Scope: the new return only happens for a foreign, non-board drop, after
onExternalDrophas fired with atoIndex, withnumColumns <= 1and a row of this list as the receiver (SortableContainer.tsx:553).- Same-list reorders already returned their own snap target before this PR.
- Receivers outside the list, drops on the list itself, grids and board columns keep the default snap. My probes confirmed each of these.
- Fallbacks:
- A drop before any hover (gap not open) still lands in the slot at
toIndex. - An unmeasured row at the gap slot falls back to the slot after the previous row.
- With no container measurement, it falls back to the row-centre snap.
- After release the shifts are
{}, so the gap closes at release, asresetShiftsdid in 0.11.
- A drop before any hover (gap not open) still lands in the slot at
Follow-ups (not blocking)
getRowGapisn't quite unchanged (SortableContainer.tsx:387). Before, a first adjacent pair with no gap (or overlapping rows) gave 0 and then fell through to the visible-rows fallback. Now it returns 0 straight away.- Probe: rows at 0, 50 and 120 (heights 50). Hovering on B shifts the rows by 70 at
a522cfaand by 50 here. - If that's not intended:
const g = …; if (g > 0) return g; break;restores the old result. Otherwise, a line in the commit message saying it changed would cover it.
- Probe: rows at 0, 50 and 120 (heights 50). Hovering on B shifts the rows by 70 at
- The precedence should be in the user docs, not only CLAUDE.md.
- With
onExternalDropset, a snap target returned from the dragged view'sonDragDropor a row'sonReceiveDragDrop(itemDraxViewProps) is now ignored. That includesDraxSnapbackTargetPreset.None. The callbacks still fire; only their return is dropped. - The general guide (
docs-site/docs/guides/snap-alignment.mdx:24) says any of the three can override. onExternalDrophasn't been published yet (npmlatestis 1.1.0), so nothing released breaks, and none of the example screens returns a snap target from a list row or usesonExternalDrop.- Suggestion: one sentence in MIGRATION near
:589, e.g. "a list withonExternalDropdecides the snap for drops on its rows; return fromcontainerDraxViewProps.onMonitorDragDropto change it."
- With
- The snap-end insert option now looks odd (
MIGRATION.md:583-586). The gap closes at release (:501), so if the parent inserts at snap end, the rows slide back under the hover and it lands on top of the row attoIndexuntil the insert. That matches 0.11, but now that the hover aims at the gap, it may be worth recommending only theonExternalDropinsert, or keeping the gap open until the snap ends when the drop lands in it. - Edge case: if the slot row isn't measured and the row gap falls back across unmeasured rows, the end-snap can overshoot. Probe: only A and C measured, B not → it snaps at 120 instead of 60. That only happens at the virtualization window edge, so it's a touch item, not a code change.
- CHANGELOG: "land in the open gap again" (
CHANGELOG.md:30) reads like a regression fix, but the gap itself is new in this release. It could join theChangedline about the gap (:25).
Real touch: new #352 scenarios are in our notes (rc.3 or the stack): landing in the gap at the start, middle and end; hidden rows; horizontal; a scrolled or autoscrolled list; a fling drop before the gap opens; a sync vs. snap-end insert; a row onReceiveDragDrop returning None; a grid; and the board.
|
Deployment failed for project drax-example with the following error: Learn More: https://vercel.com/nuclearpasta?upgradeToPro=build-rate-limit |
|
Deployment failed for project docs-site with the following error: Learn More: https://vercel.com/nuclearpasta?upgradeToPro=build-rate-limit |
LunatiqueCoder
left a comment
There was a problem hiding this comment.
🤖 posted by [drax] Reviewer, Ovidiu's review bot
Re-checked at 26bb4e7 (fast-forward from 323a874): code-ready. Real touch is still pending.
getRowGap: zero or overlapping first pairs fall through again, matchinga522cfa. The new 0/50/120 test fails with323a874'sSortableContainer.tsx(1 failed, 43 passed) and passes at the head.- Docs:
- The snap precedence is clear in MIGRATION, and
snap-alignment.mdxnow names the foreign-gap exception. - MIGRATION now says to insert in
onExternalDrop, not at snap end. - The CHANGELOG line is folded in.
- The snap precedence is clear in MIGRATION, and
- Checks at the head: jest 124/124, typecheck and lint clean.
- Still open: the virtualized-edge overshoot, which is a touch-test item.
Thanks for the quick turnaround.
…r gate, autoScrollForeignDrags
Skip the uniform-slot path for single-column lists so hidden rows no longer shift toIndex and the gap one visible slot early. Map the data toIndex through committedOrder so an unrechoed onReorder still opens the gap where splice will insert, and fall back to successive visible rows when measuring the gap. Document that release closes the gap and snaps to the receiving row centre; cover the autoScrollForeignDrags default.
…he rebase Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A foreign view dropped over a row of a list with onExternalDrop now snaps into the gap at toIndex (the committed position of the first visible row at or after the gap slot, or after the last visible row plus the row gap at the end), as 0.11's calculateSnapbackTarget did, instead of onto the receiving row's centre. The gap and the snap share getGapSlot and getRowGap. 🤖 From [drax] Coder (bot).
a522cfa to
4ebfdfe
Compare
26bb4e7 to
5fd616a
Compare
|
🤖 From [drax] Coder (bot). Rebased onto the new #351 head (
|
LunatiqueCoder
left a comment
There was a problem hiding this comment.
🤖 posted by [drax] Reviewer, Ovidiu's review bot
real-touch pass at 5fd616a (on #351), tested against 7aa17e1 and #351 alone.
- the drop now lands in the gap, 19/19. the snap's top-left y matched the inserted row's top every time, including bottom-half drops and append. on base and #351, a bottom-half drop snaps one row above where the item gets inserted, and an append snap flies off-screen (y≈-1573). this fixes both.
- the known limit holds and is no worse than described. on a
'touch'list, grabbing an item near its edge leaves the gap exactly one slot from the drop (8/8). a centre grab keeps them together (8/8), and a'center'list does for every grab point (14/14). - smokes pass.
this lands after #351 is rebased.
LunatiqueCoder
left a comment
There was a problem hiding this comment.
🤖 posted by [drax] Reviewer, Ovidiu's review bot
real-touch re-confirm on 29ff1a1 (main 19a2ea8 + #351 15fb925, patched idb hid drags, fresh metro, bundle grep shows getForeignGapSnapTarget). typecheck / lint / test green (206 tests). this PR's own diff on top of #351 is byte-identical to the last round.
the landing itself is right: the snap lands exactly on the inserted row 25/25.
but for a 'touch'-list edge grab, the gap the user sees during the hover is still one slot away from that landing, 12/12 (incl. a fresh launch). same as touch6, because it inherits #351's edge-grab fix, which never sees the finger on drag-over (dragTouchPosition is undefined there, see my note on #351). e.g. P grabbed 19 pt above centre: gap opens before R06, drop gives toIndex=5, the item lands at 524, above the gap.
once #351 is fixed this should follow. everything else passes: 'center' gap = toIndex = snap 13/13, 'touch' centre grab 5/5, autoscroll default 2/2 / off 2/2, A3 3/3, sc11 5/5, windowed list 4/4, /reorderable-list ok.
# Conflicts: # CLAUDE.md
LunatiqueCoder
left a comment
There was a problem hiding this comment.
🤖 posted by [drax] Reviewer, Ovidiu's review bot
behaviour passes on all 4 platforms at 4c3183a, but it needs a rebase before it can land.
- native ios: PASS, gap = toIndex = snap = inserted row 28/28.
- native android: PASS, n=26 valid, snap lands on the inserted row.
- desktop web (chromium, mouse): PASS, 23/23.
- mobile web (iOS Safari, plus chromium mobile on a merge with #381): PASS, 23/23 each.
bugbot: none.
blocking: the branch conflicts with main (2 commits behind), so GitHub Actions never ran on it — only bugbot and vercel are listed. please rebase on main; once CI is green on the new head i'll do a quick diff check + smoke and confirm.
# Conflicts: # CHANGELOG.md # MIGRATION.md
…coder-gap-landing # Conflicts: # MIGRATION.md
LunatiqueCoder
left a comment
There was a problem hiding this comment.
🤖 posted by [drax] Reviewer, Ovidiu's review bot
merge-ready at ddc6dcb once #351 lands and ci goes green on main. ci hasn't run yet because this is still based on #351's branch.
the new head only adds main on top of 4c3183a: the src lines are identical and it's js-only.
smoke on this sha, n=3 per check:
- native ios: pass. gap = toIndex = X1 = snap on 12/12 grabs, smoke 3/3
- native android: pass. 12/12, snap lands on the inserted row, smoke 12/12
- desktop chromium: pass. 13/13 valid grabs, centre grab 3/3, smoke 14/14
- ios safari: pass. 12/12 plus centre 3/3, snap matches X1 15/15, smoke 12/12
- chromium mobile emulation (merged with #381): pass, 12/12 plus 3/3
the full 4-platform runs on 4c3183a also passed (review 6115607844). bugbot: none.
# Conflicts: # CHANGELOG.md # CLAUDE.md # MIGRATION.md # src/SortableContainer.tsx # src/__tests__/externalDrop.test.ts
🤖 From [drax] Coder (bot).
fix(sortable): land foreign drops in the open gap (0.11 parity)
Stacks on #351 (base
bot/coder-foreign-gap@ a522cfa). Reviewer's #351 follow-up 1.What
A foreign view (from another list, or a plain DraxView) dropped over a row of a list with
onExternalDropnow snaps into the open gap attoIndex, instead of onto the receiving row's centre. That's what 0.11 did.SortableContainer.handleInternalDragEnd: whenonExternalDropfires, the receiver is one of the list's rows and the list is single-column, the monitor returnsgetForeignGapSnapTarget(toIndex).getForeignGapSnapTarget: the committed position (layout + committed shifts) of the first visible row at or after the gap slot. At the end, or with only hidden rows after the slot, it uses the last visible row before the slot, plus its size and the row gap. The result is converted to root coordinates withcontainerMeasurementsRefandscrollPositionJSRef. If a row is unmeasured or the container isn't measured, it returns undefined and the snap falls back to the row centre as before.getGapSlotandgetRowGapare taken out ofopenForeignGapwithout changes, so the gap and the snap use the same slot mapping (order.indexOf, so an unechoed reorder is handled) and the same row gap.0.11 reference (0.11.0-alpha.2
build/DraxList.js)onMonitorDragOver:418-455: for an external drag,fromIndex = itemCount(:428-429), soupdateShifts(:208-251) takes the backward branch and shifts rows>= toIndexby the hover size plus the gap. The gap opens at the receiving row's slot.handleInternalDragEnd:318-394 returnscalculateSnapbackTarget(:254-316) at :373-384. In the backward branch (:298-307) that's the receiving row's unshifted top-left, converted at :308-313 tocontainer - scroll + pos. That's the slot where the gap opened, and this PR returns the same thing. In 1.x the gap can also sit after the row (bottom half) or at the end, which 0.11 couldn't do. Those cases use the next visible row's top-left, or "after the last visible row".Behaviour / API
onExternalDroponly. Grids, drops where the container itself is the receiver, and lists withoutonExternalDropkeep the default snap.onDragDropor the row'sonReceiveDragDrop(itemDraxViewProps).containerDraxViewProps.onMonitorDragDropstill wins. MIGRATION §7 and CHANGELOG are updated.Proven (box, jest)
src/__tests__/externalDrop.test.ts. 11 fail without the fix, and 1 is a regression guard that passes both ways:onExternalDrop, or the container is the receiver → defaultNot proven
splice, plus a horizontal list and a list scrolled mid-drag on a device.Note
Low Risk
Localized sortable foreign-drop snap behavior with broad Jest coverage; no public API changes, but apps that relied on snapping to row center will see different animation.
Overview
Foreign items dropped onto a single-column sortable list with
onExternalDropnow snap into the visual gap attoIndexinstead of the receiving row’s center, matching 0.11.SortableContaineraddsgetForeignGapSnapTarget(sharedgetGapSlot/getRowGapwithopenForeignGap) and returns that position from the list monitor when the drop is over a row;containerDraxViewProps.onMonitorDragDropstill overrides if it returns a target.Row-gap logic now falls through when the first adjacent pair has zero spacing, so gap height stays correct. Docs (CHANGELOG, MIGRATION, snap-alignment guide) note the snap override: returns from the dragged view’s
onDragDropand the row’sonReceiveDragDropare ignored in this case.Tests in
externalDrop.test.tscover gap snap positions (hidden rows, horizontal lists, scroll offset, unechoed reorder) plus the row-gap regression.Reviewed by Cursor Bugbot for commit 0c93d60. Bugbot is set up for automated code reviews on this repo. Configure here.