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