Skip to content

Commit cccf009

Browse files
committed
Bugfix: Drag the file under the cursor
Clicking on the entry already under the cursor started the click-to-rename timer and returned early, so it never initiated drag tracking. Grabbing the cursor item — alone or as part of a multi-file selection — did nothing. - Fall through to drag tracking in `FullList`/`BriefList` after starting the rename timer. - Cancel the rename timer in `drag-drop.ts` once the drag threshold is crossed, so it doesn't fire mid-drag.
1 parent 96f4bbd commit cccf009

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

apps/desktop/src/lib/file-explorer/drag/drag-drop.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { tempDir, join } from '@tauri-apps/api/path'
1414
import { getCachedIcon } from '$lib/icon-cache'
1515
import { startSelectionDrag, prepareSelfDragOverlay, clearSelfDragOverlay } from '$lib/tauri-commands'
1616
import { getSetting } from '$lib/settings/settings-store'
17+
import { cancelClickToRename } from '../rename/rename-activation'
1718
import { renderDragImage } from './drag-image-renderer'
1819

1920
/** Gets the drag threshold from settings (minimum distance in pixels to trigger drag) */
@@ -276,6 +277,9 @@ export function startSelectionDragTracking(
276277
const ctx = activeDrag.context
277278
const cbs = activeDrag.callbacks
278279

280+
// Stop any pending click-to-rename timer so it doesn't fire mid-drag.
281+
cancelClickToRename()
282+
279283
// For single-file drag, call onDragStart to select the file first
280284
if (ctx.type === 'single') {
281285
cbs.onDragStart?.()

apps/desktop/src/lib/file-explorer/views/BriefList.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,15 @@
258258
259259
// Click-to-rename: if clicking the entry already under the cursor
260260
// (without Shift), start a timer that activates rename after 800ms.
261-
// Skip when rename is already active.
261+
// Drag tracking still runs below so the cursor item remains draggable —
262+
// crossing the drag threshold cancels the rename timer.
262263
if (index === cursorIndex && !event.shiftKey && !renameState?.active && onStartRename) {
263264
startClickToRename(event, onStartRename)
264-
return
265+
} else {
266+
// Clicking a different entry cancels any pending click-to-rename timer
267+
cancelClickToRename()
265268
}
266269
267-
// Clicking a different entry cancels any pending click-to-rename timer
268-
cancelClickToRename()
269-
270270
const hasSelection = selectedIndices.size > 0
271271
272272
if (!hasSelection) {

apps/desktop/src/lib/file-explorer/views/FullList.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@
252252
253253
// Click-to-rename: if clicking the entry already under the cursor
254254
// (without Shift), start a timer that activates rename after 800ms.
255-
// Skip when rename is already active.
255+
// Drag tracking still runs below so the cursor item remains draggable —
256+
// crossing the drag threshold cancels the rename timer.
256257
if (index === cursorIndex && !event.shiftKey && !renameState?.active && onStartRename) {
257258
startClickToRename(event, onStartRename)
258-
return
259+
} else {
260+
// Clicking a different entry cancels any pending click-to-rename timer
261+
cancelClickToRename()
259262
}
260263
261-
// Clicking a different entry cancels any pending click-to-rename timer
262-
cancelClickToRename()
263-
264264
const hasSelection = selectedIndices.size > 0
265265
266266
if (!hasSelection) {

0 commit comments

Comments
 (0)