From 11202a92e79dd6f1243e413539fff6bc6e14e2e1 Mon Sep 17 00:00:00 2001 From: Claudio Date: Mon, 11 May 2026 10:47:02 +0200 Subject: [PATCH] fix(preview): cull/pick shortcuts target the visible photo, not stale selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Arrow nav inside preview only updates activePhotoId; selectedPhotos still points at whatever was selected in the grid before opening preview. X and S therefore fired against the wrong photo — the toast appeared but the filmstrip tint for the currently-viewed photo never changed because that photo was not the cull target. cullTargets() (and togglePickOnSelection, now sharing it) now prefer activePhotoId when viewMode === preview. --- frontend/src/hooks/useKeyboardShortcuts.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/hooks/useKeyboardShortcuts.ts b/frontend/src/hooks/useKeyboardShortcuts.ts index 6265da3..07c8547 100644 --- a/frontend/src/hooks/useKeyboardShortcuts.ts +++ b/frontend/src/hooks/useKeyboardShortcuts.ts @@ -219,6 +219,11 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) { } /** The set of photo ids the next culling action should apply to. + * - Preview mode → the currently-viewed photo (activePhotoId), since + * arrow nav inside preview only updates activePhotoId and leaves + * selectedPhotos pointing at whatever the user selected in the grid + * before opening preview. Honouring selectedPhotos here would cull + * the wrong photo and the filmstrip tint wouldn't appear to react. * - Multi-selection → all selected photos * - Single selection → that one photo * - No selection but an activePhotoId set (last clicked) → that one @@ -226,6 +231,9 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) { */ const cullTargets = (): string[] => { const state = usePhotoStore.getState() + if (state.viewMode === 'preview') { + return state.activePhotoId ? [state.activePhotoId] : [] + } if (state.selectedPhotos.length > 0) return state.selectedPhotos if (state.activePhotoId) return [state.activePhotoId] return [] @@ -342,13 +350,9 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) { }) const togglePickOnSelection = () => { - const state = usePhotoStore.getState() - const ids = - state.selectedPhotos.length > 0 - ? state.selectedPhotos - : state.activePhotoId - ? [state.activePhotoId] - : [] + // Reuse cullTargets so preview-mode arrow-nav targets the visible + // photo, not the stale grid selection (same fix as X / discard). + const ids = cullTargets() if (ids.length === 0) { toast.info('Nothing selected', 'Select photos first, then press S') return