fix(ios): make ordering question drag-and-drop work on iOS Safari#45
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
MichalTheProgrammer
left a comment
There was a problem hiding this comment.
Let's test on prod!
Problem
The Ordering question relied on the native HTML5 Drag and Drop API
(
draggable+onDragStart/Over/End). iOS Safari does not fire theseevents for touch input, so reordering was impossible on iPhone/iPad -
touching a tile just scrolled the page.
Fix
Replaced native DnD with @dnd-kit:
PointerSensor- built on Pointer Events, which iOS Safarisupports. This is the core fix.
setActivatorNodeRef+touch-noneon the handle only) - on touch you drag via the grip,while touching the rest of the row still scrolls the list.
KeyboardSensor- the list can now also be reordered viakeyboard (a11y bonus).
arrayMoveinonDragEnd.The
onSubmitcontract is unchanged - it still returnsnumber[](original indices in their new order), so
PlayingShellneeds nochanges.
Adds deps:
@dnd-kit/core,@dnd-kit/sortable,@dnd-kit/utilities.Behavior change
Dragging now starts from the grip handle only (previously the whole
row was draggable). Intentional: it lets touch users scroll the list,
and the grip icon already signals the drag affordance.
Test plan
eslint --max-warnings=0,prettier,tsc --noEmitpassSummary by CodeRabbit