feat: disable merge during rearrange#557
Conversation
|
Closes #553 |
WalkthroughThe changes implement drag and reorder state management across multiple components. A new 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
frontend/src/components/WikiDocumentList.vue (1)
570-580: Consider guarding against post-unmount side effects from in-flight reorders.If the component unmounts while
reorderInFlightistrue, theapplyReorderpromise'sfinallyblock (Lines 322–329) will still execute, callingflushReorder()and mutating refs on an unmounted component. In Vue 3 this is benign (emit becomes a no-op, ref writes are harmless), but it's a latent concern if the logic ever grows more complex.A lightweight guard would be:
💡 Optional: add an `isMounted` guard
+let isMounted = true; + onBeforeUnmount(() => { + isMounted = false; if (reorderTimer) { clearTimeout(reorderTimer); reorderTimer = null; }Then in
flushReorder'sfinally:} finally { reorderInFlight = false; + if (!isMounted) return; if (pendingReorder) { flushReorder();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/components/WikiDocumentList.vue` around lines 570 - 580, The component can be unmounted while applyReorder is still in flight causing flushReorder's finally to mutate refs and emit on an unmounted component; add a simple isMounted boolean (set true in onMounted and false in onBeforeUnmount) and check it at the start of flushReorder's finally block (and before any ref writes or emit calls) so flushReorder no-ops if the component is unmounted, keeping existing logic in applyReorder and onBeforeUnmount intact; reference functions/refs: applyReorder, flushReorder, reorderInFlight, onBeforeUnmount, isReorderBusy, isDragActive, pendingReorder and the 'reorder-state-change' emit.frontend/src/components/NestedDraggable.vue (1)
378-384: Unconditionaldrag-state-change(false)on unmount is fine but slightly noisy.Every
NestedDraggableinstance (including deeply nested ones) emitsdrag-state-change(false)on unmount even when no drag is active. SinceWikiDocumentList.handleDragStateChangejust assigns the value, last-write-wins tofalseis correct and harmless. Optionally, guard the emit:💡 Optional: guard the unmount emission
onBeforeUnmount(() => { if (dragSettleTimer) { clearTimeout(dragSettleTimer); dragSettleTimer = null; } - emit('drag-state-change', false); + if (isDragging.value || dragSettleTimer) { + emit('drag-state-change', false); + } });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/components/NestedDraggable.vue` around lines 378 - 384, Unconditional emit of 'drag-state-change', false in NestedDraggable.onBeforeUnmount is noisy; change the unmount handler to only emit when this instance actually has an active drag (e.g., check a local isDragging flag or the existing dragSettleTimer) so you only call emit('drag-state-change', false) if a drag is in progress; update NestedDraggable (onBeforeUnmount) to guard the emit using the local dragging indicator (or dragSettleTimer) and leave WikiDocumentList.handleDragStateChange unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/src/components/NestedDraggable.vue`:
- Around line 378-384: Unconditional emit of 'drag-state-change', false in
NestedDraggable.onBeforeUnmount is noisy; change the unmount handler to only
emit when this instance actually has an active drag (e.g., check a local
isDragging flag or the existing dragSettleTimer) so you only call
emit('drag-state-change', false) if a drag is in progress; update
NestedDraggable (onBeforeUnmount) to guard the emit using the local dragging
indicator (or dragSettleTimer) and leave WikiDocumentList.handleDragStateChange
unchanged.
In `@frontend/src/components/WikiDocumentList.vue`:
- Around line 570-580: The component can be unmounted while applyReorder is
still in flight causing flushReorder's finally to mutate refs and emit on an
unmounted component; add a simple isMounted boolean (set true in onMounted and
false in onBeforeUnmount) and check it at the start of flushReorder's finally
block (and before any ref writes or emit calls) so flushReorder no-ops if the
component is unmounted, keeping existing logic in applyReorder and
onBeforeUnmount intact; reference functions/refs: applyReorder, flushReorder,
reorderInFlight, onBeforeUnmount, isReorderBusy, isDragActive, pendingReorder
and the 'reorder-state-change' emit.
Screen.Recording.2026-02-19.at.5.17.08.PM.mov
Summary by CodeRabbit