allusion-app / Allusion

A free and open source desktop application for managing your visual library
GNU General Public License v3.0
662 stars 42 forks source link

When clearing search terms, scroll position doesn't navigate to last highlighted image #576

Open partrap opened 1 year ago

partrap commented 1 year ago

Praise: New here – Allusion is wonderful and just what I've been looking for.

Issue: After finding an item with search, sometimes I want to see the selected item in 'context' of the whole library. When sorting by Date Added this useful for finding items I know were added together.

What I expect:

  1. Search library.
  2. Click to highlight a single item in search results.
  3. Clear search terms.
  4. Hit an arrow key to shift the window scroll position/focus to the highlighted item in context of library.

I assume this is a bug because without searching the library the expected behaviour (window focus shifts to highlighted item) does happen.

Cheers!

RvanderLaan commented 1 year ago

:heart:

Keyboard navigation with the cursor keys was quite tricky to get right. The selection state is kept track of in a global store, where it can be preserved when the gallery is updated with other images since the before and after states are known there. However, the focused item in the gallery is currently stored in a local state in the gallery, where that information is not known, so we opted to just reset that state when the gallery is updated

image

Over there, there would have to be a lookup of what the image at lastSelectionIndex was, and update it to that image's index in the new list of images. That would require lifting that state into the global store too. That's not the most fun type of work, but I'll put it on the TODO list!