fix(preview): cull/pick shortcuts target the visible photo, not stale selection
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.
This commit is contained in:
@@ -219,6 +219,11 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The set of photo ids the next culling action should apply to.
|
/** 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
|
* - Multi-selection → all selected photos
|
||||||
* - Single selection → that one photo
|
* - Single selection → that one photo
|
||||||
* - No selection but an activePhotoId set (last clicked) → that one
|
* - No selection but an activePhotoId set (last clicked) → that one
|
||||||
@@ -226,6 +231,9 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) {
|
|||||||
*/
|
*/
|
||||||
const cullTargets = (): string[] => {
|
const cullTargets = (): string[] => {
|
||||||
const state = usePhotoStore.getState()
|
const state = usePhotoStore.getState()
|
||||||
|
if (state.viewMode === 'preview') {
|
||||||
|
return state.activePhotoId ? [state.activePhotoId] : []
|
||||||
|
}
|
||||||
if (state.selectedPhotos.length > 0) return state.selectedPhotos
|
if (state.selectedPhotos.length > 0) return state.selectedPhotos
|
||||||
if (state.activePhotoId) return [state.activePhotoId]
|
if (state.activePhotoId) return [state.activePhotoId]
|
||||||
return []
|
return []
|
||||||
@@ -342,13 +350,9 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const togglePickOnSelection = () => {
|
const togglePickOnSelection = () => {
|
||||||
const state = usePhotoStore.getState()
|
// Reuse cullTargets so preview-mode arrow-nav targets the visible
|
||||||
const ids =
|
// photo, not the stale grid selection (same fix as X / discard).
|
||||||
state.selectedPhotos.length > 0
|
const ids = cullTargets()
|
||||||
? state.selectedPhotos
|
|
||||||
: state.activePhotoId
|
|
||||||
? [state.activePhotoId]
|
|
||||||
: []
|
|
||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
toast.info('Nothing selected', 'Select photos first, then press S')
|
toast.info('Nothing selected', 'Select photos first, then press S')
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user