makemd icon indicating copy to clipboard operation
makemd copied to clipboard

fix(navigator): resolve drag-drop reordering snap-back and validation…

Open acjnn opened this issue 1 month ago • 1 comments

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

  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 some users reported
    • Added rollback mechanism if database write fails
    • Preserved previous tree state for calculations to avoid race conditions

acjnn avatar Nov 11 '25 21:11 acjnn

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.

jp-cen avatar Nov 12 '25 16:11 jp-cen