fix(navigator): resolve drag-drop reordering snap-back and validation…#519
Draft
acjnn wants to merge 1 commit intoMake-md:mainfrom
Draft
fix(navigator): resolve drag-drop reordering snap-back and validation…#519acjnn wants to merge 1 commit intoMake-md:mainfrom
acjnn wants to merge 1 commit intoMake-md:mainfrom
Conversation
… issues Fixes Make-md#443, Make-md#408, Make-md#160 This commit addresses multiple critical issues with manual reordering in the space navigator that caused items to snap back to their original positions or behave unpredictably during drag-and-drop operations. **Issues Fixed:** 1. **Sortable Logic Clarity** (dragPath.ts line 89-94) - Added explicit comments explaining sortable determination - Fixed edge case where nextItem could be undefined - Made the boolean logic more readable and maintainable 2. **Type Coercion Bug** (dropPath.ts lines 43-48, 67-70) - Removed dangerous 'boolean && number' pattern that caused false to coerce to 0 - Added explicit validation to reject drops on non-sortable spaces - Users now receive clear feedback when dropping in unsorted folders - Prevents silent failures and unexpected behavior 3. **Optimistic UI Updates** (SpaceTreeView.tsx lines 196-252, 614-657) - Implemented optimistic rendering to update UI immediately on drop - Prevents the 'snap-back' visual glitch users experienced - Added rollback mechanism if database write fails - Preserved previous tree state for calculations to avoid race conditions - Significantly improves perceived performance and user experience **Technical Details:** - The snap-back occurred because the UI reset immediately while the async database write was queued, leaving users looking at stale data - Type coercion bug allowed invalid index values (false = 0) to be passed to reordering functions, causing items to jump to unexpected positions - Optimistic updates now provide instant visual feedback while the actual database operations complete in the background **Testing Notes:** - Manual drag-drop reordering should now feel instant and responsive - Dropping into non-manually-sorted folders shows appropriate error message - Failed reorders will rollback to previous state with notification - Multiple rapid reorders are handled more gracefully
3b66fd3 to
77c1951
Compare
Contributor
|
Thanks for the effort into fixing this. I'm aware of the issue and it's prioritized into the next version. There are some good suggestions that were added here like optimistic reordering so the UI looks smoother, but the underlying issue with the ordering not saving is more related to a data refresh issue due to some other optimizations that were made recently. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit addresses a few issues with manual reordering in the space navigator that caused items to behave unpredictably during drag-and-drop operations.
Issues Fixed:
#443, #408, #160
Sortable Logic Clarity (dragPath.ts line 89-94)
Type Coercion Bug (dropPath.ts lines 43-48, 67-70)
Optimistic UI Updates (SpaceTreeView.tsx lines 196-252, 614-657)