Skip to content

fix(sidebar): correct task reorder drop position after auto-scroll - #3170

Open
claude[bot] wants to merge 1 commit into
mainfrom
fix/sidebar-reorder-pointer-position
Open

fix(sidebar): correct task reorder drop position after auto-scroll#3170
claude[bot] wants to merge 1 commit into
mainfrom
fix/sidebar-reorder-pointer-position

Conversation

@claude

@claude claude Bot commented Sep 8, 2026

Copy link
Copy Markdown

Requested by Raban von SpiegelSlack thread

Before: Dragging a task (or project) in the left sidebar far enough for the list to auto-scroll made the insertion indicator jump to the wrong side of the hovered row, and the drop landed one slot away from where the indicator had been. Short drags that did not scroll the list behaved correctly, which is why the reordering felt "glitchy" rather than broken.

After: The indicator stays on the side of the row the pointer is actually on, and the drop lands where the indicator shows, regardless of how far the list scrolled during the drag.

How: The drag handlers tracked the pointer as initialPointerY + delta.y, but dnd-kit's delta is scroll-adjusted (pointer travel plus the scroll container's movement since drag start), while over.rect reads in viewport space. Once the list scrolled by half a row the above/below comparison flipped. The fix records the list's scrollTop at drag start and subtracts the scroll delta on each move, so the tracked pointer stays in viewport space to match the rect it is compared against. Both the insertion indicator and the drop decision read the same corrected value.

Related issues

Reported on Discord ("reordering tasks is a bit glitchy").

Testing

  • oxfmt --check on the changed file
  • pnpm run lint in apps/emdash-desktop plus tooling/oxlint/scripts/check-allowlists.mjs
  • nx run @emdash/emdash-desktop:typecheck (browser, node, and release tsconfigs)
  • vitest run --project node src/core/features/workbench/browser/sidebar (15 tests pass)

No new unit test: the corrected math lives inline in the component's drag handlers and there is no existing test harness for the virtualized sidebar's DnD wiring.

Checklist
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for commit
    messages and, when possible, the PR title

馃 Generated with Claude Code

https://claude.ai/code/session_01AymqGXQwXJbLX2JmA5FPFh


Generated by Claude Code

The sidebar drag handlers tracked the pointer as `initialPointerY +
delta.y`, but dnd-kit's `delta` is scroll-adjusted: it adds however far
the list's scroll container has moved since the drag began. The
above/below decision then compared that scroll-offset Y against
`over.rect`, whose getters read in viewport space. Once the list had
auto-scrolled by half a row or more, the insertion indicator flipped to
the wrong side and the drop landed one slot off.

Record the list's scrollTop at drag start and subtract the scroll delta
on each move so the tracked pointer stays in viewport space, matching
the rect it is compared against.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AymqGXQwXJbLX2JmA5FPFh
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects sidebar reorder positioning during auto-scroll by keeping the tracked drag pointer in the same viewport coordinate space as the hovered row rectangle.

  • Captures the sidebar list鈥檚 initial scrollTop when dragging starts.
  • Removes subsequent list scroll movement from dnd-kit鈥檚 adjusted drag delta.
  • Continues using one corrected pointer value for both the insertion indicator and final drop decision.

Confidence Score: 5/5

The PR appears safe to merge; the coordinate correction is localized and consistently feeds both visual and final reorder decisions.

No actionable failure remains: the corrected pointer uses the list鈥檚 actual scroll container, stays in viewport coordinates, and is shared by the insertion indicator and drop calculation.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/core/features/workbench/browser/sidebar/sidebar-virtual-list.tsx Captures the initial sidebar scroll offset and removes accumulated list scrolling from drag pointer calculations so indicator and drop placement remain aligned.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Drag starts] --> B[Capture pointer Y and scrollTop]
  B --> C[Drag move supplies adjusted delta]
  C --> D[Subtract list scroll delta]
  D --> E[Viewport-space pointer Y]
  E --> F[Compare with hovered row midpoint]
  F --> G[Render insertion indicator]
  F --> H[Choose final insertion index]
Loading

Reviews (1): Last reviewed commit: "fix(sidebar): correct task reorder drop ..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant