fix: pass visible sequence to openPreview from the click site
Previously the visible photo order was published only via a passive useEffect on Timeline, which had a timing race: arrow nav in preview could read a stale or empty sequence and fall back to the raw API order, breaking visual order navigation in tag mode and after filter changes. Fix: openPreview now accepts an optional visibleSequence parameter, and Timeline's onDoubleClick passes the freshly-computed flat sequence directly. The store action adopts that sequence as the authoritative visiblePhotoIds for the preview session, falling back to the most-recently-published one for paths that don't have a click site (e.g. the global Space hotkey). The Timeline still publishes via useEffect for the Space-hotkey fallback path, but the click path no longer depends on it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -297,20 +297,27 @@ export function Timeline() {
|
||||
[items]
|
||||
)
|
||||
|
||||
// Publish the flat visible-order id sequence to the photo store so
|
||||
// PreviewView arrow nav (and the filmstrip) walks the same order the
|
||||
// user sees in the grid. Includes duplicates from tag grouping —
|
||||
// landing on the same photo's "second" appearance in the next tag
|
||||
// bucket is the right behavior in tag mode.
|
||||
useEffect(() => {
|
||||
// Flat visible-order id sequence — exactly the order the user reads
|
||||
// off the grid (top-to-bottom, left-to-right within each row).
|
||||
// Includes duplicates from tag-grouping; landing on the same photo's
|
||||
// "second" appearance in the next tag bucket is the right behavior
|
||||
// in tag mode.
|
||||
const visibleSequence = useMemo(() => {
|
||||
const ids: string[] = []
|
||||
for (const row of photoRows) {
|
||||
for (const cell of row.cells) {
|
||||
ids.push(cell.photo.id)
|
||||
}
|
||||
}
|
||||
setVisiblePhotoIds(ids)
|
||||
}, [photoRows, setVisiblePhotoIds])
|
||||
return ids
|
||||
}, [photoRows])
|
||||
|
||||
// Publish to the photo store so PreviewView's arrow nav and filmstrip
|
||||
// can walk the same order even when opened from a non-click path
|
||||
// (e.g. the global Space hotkey).
|
||||
useEffect(() => {
|
||||
setVisiblePhotoIds(visibleSequence)
|
||||
}, [visibleSequence, setVisiblePhotoIds])
|
||||
|
||||
// Locate the active photo in the visual grid. Returns the FIRST
|
||||
// (rowIndex, colIndex) where its id appears, since a tag-grouped view
|
||||
@@ -518,7 +525,7 @@ export function Timeline() {
|
||||
selectPhoto(photo.id, globalIndex)
|
||||
}
|
||||
}}
|
||||
onDoubleClick={() => openPreview(photo.id)}
|
||||
onDoubleClick={() => openPreview(photo.id, visibleSequence)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user