-
Notifications
You must be signed in to change notification settings - Fork 146
fix: improve reorder icon scale reset and add aria/touch optimizations #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA drag-items component refactors its ReorderIcon API: replaces Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Item
participant ReorderIcon
participant DragControls
Note over Item,ReorderIcon: New flow — press + drag unified by isActive
User->>Item: PointerDown
Item->>ReorderIcon: onPress()
ReorderIcon->>Item: pressed = true
Item->>Item: isActive = isDragging || pressed
Item->>DragControls: startDrag (when applicable)
User->>Item: PointerUp / PointerCancel / DragEnd
Item->>Item: pressed = false
Item->>ReorderIcon: isActive = false
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (4)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/ui-layout/registry/components/drag/drag-items.tsx (1)
110-114: Consider keyboard accessibility for drag initiation.The
onPointerDownhandler enables mouse and touch interaction, but there's no keyboard equivalent (e.g.,onKeyDownwith Space or Enter keys). While drag-and-drop keyboard accessibility is complex, consider adding basic keyboard support to make the reorder functionality accessible to keyboard-only users.Example enhancement:
onKeyDown={(e) => { if (e.key === ' ' || e.key === 'Enter') { e.preventDefault(); onPress(); // Note: dragControls.start() requires pointer event // Consider alternative keyboard reorder pattern } }}Note: Full keyboard drag-and-drop may require a different interaction pattern (e.g., arrow keys to reorder) since
dragControls.start()requires a pointer event.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/ui-layout/registry/components/drag/drag-items.tsx(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/ui-layout/registry/components/drag/drag-items.tsx (1)
apps/ui-layout/assets/icons/Icons.tsx (1)
IconProps(4-4)
🔇 Additional comments (3)
apps/ui-layout/registry/components/drag/drag-items.tsx (3)
70-70: LGTM! Pressed state addition addresses the core issue.The
pressedstate correctly tracks icon press events independent of drag state, ensuring the scale animation resets properly after click-without-drag interactions.
79-84: LGTM! Comprehensive state cleanup ensures reliable scale reset.The combination of
onDragEnd,onPointerUp, andonPointerCancelhandlers ensures the pressed state is reliably cleared in all scenarios, including drag completion, pointer release, and pointer interruption events.
88-92: LGTM! ReorderIcon integration correctly implements the new API.The
isActiveprop effectively combines both drag and press states, and theonPresscallback properly triggers the pressed state, providing consistent visual feedback across both interaction types.
Description
This PR refines the reorder interaction by ensuring that the drag icon correctly resets its scale in all cases — including simple clicks — and improves both accessibility and mobile usability.
Previously, the icon could remain scaled when clicked without dragging, and mobile users occasionally experienced scroll gesture interference.
Changes
The icon now properly resets its scale (
scale: 1) after drag or click interactions.Added
aria-label="Reorder"to the motion button to make it screen-reader friendly.Applied
touchAction: 'none'to the motion button to prevent scroll or zoom interference during dragging.Removed redundant
cursor-grabfrom the inner SVG, leaving it only on the button for consistency.Motivation
The reorder icon previously relied solely on the drag lifecycle (
onDragStart/onDragEnd),which caused the icon to stay scaled when the user clicked without dragging.
Additionally, touch devices could mistakenly interpret drag gestures as native scrolling.
This update ensures consistent visual feedback, accessibility compliance, and smoother mobile drag interactions.
Screenshots
ASIS
504498366-2a114a62-0215-4911-9e3f-f4c6660d7d83.mov
TOBE
2025-10-23.10.16.51.mov
Summary by CodeRabbit
Accessibility
Bug Fixes