fix(v2): clear gallery selection after deleting ROMs

The v2 delete flow cleared only the legacy v1 selection store
(romsStore.resetSelection()), leaving the v2 gallerySelection store
untouched. Since v2 multiselect and the SelectionBar read from
gallerySelection, the deleted ROMs stayed selected: the bar remained
open with stale rows and re-running a bulk action 404'd.

Drop the deleted IDs from gallerySelection via removeIds so a full
delete closes the bar while a partial delete keeps the rest selected.

Fixes #3822

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georges-Antoine Assi
2026-07-19 09:26:35 -04:00
parent b1b73479c5
commit da482e3443

View File

@@ -15,6 +15,7 @@ import storeRoms, { type SimpleRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { useSnackbar } from "@/v2/composables/useSnackbar";
import storeGalleryRoms from "@/v2/stores/galleryRoms";
import storeGallerySelection from "@/v2/stores/gallerySelection";
defineOptions({ inheritAttrs: false });
@@ -24,6 +25,7 @@ const route = useRoute();
const show = ref(false);
const romsStore = storeRoms();
const galleryRomsStore = storeGalleryRoms();
const gallerySelectionStore = storeGallerySelection();
const roms = ref<SimpleRom[]>([]);
const romsToDeleteFromFs = ref<number[]>([]);
const excludeOnDelete = ref(false);
@@ -101,6 +103,11 @@ async function deleteRoms() {
}
}
romsStore.resetSelection();
// Drop the deleted ROMs from the v2 gallery selection too — otherwise
// the SelectionBar stays open pointing at rows that no longer exist,
// and re-running an action 404s. removeIds only touches the deleted
// subset, so a partial delete keeps the rest of the selection intact.
gallerySelectionStore.removeIds(roms.value.map((rom) => rom.id));
romsStore.remove(roms.value);
galleryRomsStore.remove(roms.value);
romsStore.setRecentRoms(