mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-12 18:25:00 -05:00
feat(ui): when discarding last item, select new last instead of first
This commit is contained in:
@@ -344,7 +344,10 @@ export const CanvasSessionContextProvider = memo(
|
||||
// If an item is selected and it is not in the list of items, un-set it. This effect will run again and we'll
|
||||
// the above case, selecting the first item if there are any.
|
||||
if (selectedItemId !== null && items.findIndex(({ item_id }) => item_id === selectedItemId) === -1) {
|
||||
const prevIndex = $prevItems.get().findIndex(({ item_id }) => item_id === selectedItemId);
|
||||
let prevIndex = $prevItems.get().findIndex(({ item_id }) => item_id === selectedItemId);
|
||||
if (prevIndex >= items.length) {
|
||||
prevIndex = items.length - 1;
|
||||
}
|
||||
const nextItem = items[prevIndex];
|
||||
$selectedItemId.set(nextItem?.item_id ?? null);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user