fix: resolve keyboard reordering edge cases in DraggableList#80261
Conversation
- Configure KeyboardSensor to use Space-only for start/end drag - Block Enter key during drag to prevent MenuItem navigation conflicts - Generate unique instance ID per mount to reset DndContext state - Dispatch Escape on unmount to cancel any active keyboard drag
|
@jayeshmangwani Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c844374fa4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MobileMage I’m not sure why I was auto-assigned here. Do you remember whether any C+ was involved in the issues mentioned above? |
|
Yeah, I think @chuckdries said something about this being an edge case of sorts
Do you think I should close this? |
|
I’m not sure whether to close this or not. @chuckdries , what do you think? Should I go ahead with the review, or should someone from C+ who reviewed the above issues handle this? |
|
@jayeshmangwani You were randomly chosen by the bot because nobody was assigned to the linked issues. If you're comfortable, please review and cross platform test, and the automation will create an issue to ensure you get paid for your review. If not, we can reassign to the C+ that reviewed the original implementation |
Yes, I’m starting the PR review now. That works for me. |
|
@MobileMage, I’m starting the review, could you please complete the PR checklist? |
|
Yup, I'll do that today. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari80165.mov80166.mov80167.mov |
|
Above-mentioned three issues have been resolved. As now we are blocking the Enter key when the Space key is pressed (rearranging is still ongoing). @MobileMage Also, please rewrite the third case for “Test mouse drag after keyboard” more explicitly so it’s easier for QA to test. |
|
@MobileMage did you get a chance to look at the comment above #80261 (comment)? |
|
Yeah, I did. @jayeshmangwani |
|
Thankyou! |
chuckdries
left a comment
There was a problem hiding this comment.
Hi! Sorry for the delay on my review. Looks good overall, just wondering if we can replace the custom instanceId logic with a React useId call
| const styles = useThemeStyles(); | ||
|
|
||
| // Generate a unique ID per mount to ensure DndContext state resets when component remounts | ||
| const [instanceId] = useState(() => `${Date.now()}-${Math.random().toString(36).slice(2)}`); |
…ordering-followup
|
🚧 @chuckdries has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.3.28-0 🚀
|
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.3.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.30-3 🚀
|

Explanation of Change
This PR fixes three edge case issues with keyboard-based reordering in DraggableList that were discovered after the initial keyboard reordering implementation (#79793):
Enter key conflict: The default
@dnd-kitKeyboardSensor uses both Enter and Space to start/end drags, which conflicts with MenuItem's Enter-to-navigate behavior. Fixed by configuring KeyboardSensor to only use Space for start/end, and blocking Enter during drag via capture phase.Ghost drag replay: When closing the panel mid-drag, the drag state persisted and replayed on the next component mount. Fixed by:
useState()to force DndContext state reset on remountRelated: dnd-kit #857, dnd-kit #1367
Fixed Issues
$ #80165
$ #80166
$ #80167
Tests
Test ghost drag fix:
Test mouse drag after keyboard:
Offline tests
N/A - This is a UI interaction fix that doesn't involve network requests.
QA Steps
Same as Tests above.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari