fix: clear worktree drag from sidebar root cleanup (#3480)

This commit is contained in:
Neil
2026-05-30 14:32:50 -04:00
committed by GitHub
parent 8044be7cc7
commit dfa57ad57c
@@ -1468,6 +1468,18 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
setWorktreeDragState(WORKTREE_ROW_DRAG_INITIAL_STATE)
}, [cancelWorktreeNativeAutoscroll, cleanupWorktreePointerDrag])
const setScrollRootRef = useCallback(
(node: HTMLDivElement | null) => {
if (node === null && scrollRef.current !== null) {
// Why: sidebar drag previews and autoscroll frames are tied to the
// scroll root surface; clear them before that DOM owner disappears.
clearWorktreeDrag()
}
scrollRef.current = node
},
[clearWorktreeDrag]
)
const flushWorktreePointerDrag = useCallback(() => {
const drag = worktreePointerDragRef.current
if (!drag) {
@@ -2234,8 +2246,6 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
return () => document.removeEventListener('visibilitychange', handleVisibilityChange)
}, [clearWorktreeDrag])
useEffect(() => () => clearWorktreeDrag(), [clearWorktreeDrag])
useWorkspaceStatusDocumentDrop(
scrollRef,
onMoveWorktreeToStatus,
@@ -2251,7 +2261,7 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp
return (
<div data-worktree-sidebar-container className="relative min-h-0 flex-1">
<div
ref={scrollRef}
ref={setScrollRootRef}
data-worktree-sidebar
tabIndex={0}
role="listbox"