Skip to content

The swiss army knife of lossless video/audio editing

make sure to select previous item when deleting from batch list

Mikael Finstadb5ba38adb2a8
diff --git a/src/App.jsx b/src/App.jsx
index a4b8ef29..ca5013b4 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1060,8 +1060,17 @@ const App = memo(() => {
}, [askBeforeClose]);
const batchRemoveFile = useCallback((path) => {
- setBatchFiles((existingBatch) => existingBatch.filter((existingFile) => existingFile.path !== path));
- setSelectedBatchFiles([]);
+ setBatchFiles((existingBatch) => {
+ const index = existingBatch.findIndex((existingFile) => existingFile.path === path);
+ if (index < 0) return existingBatch;
+ const newBatch = [...existingBatch];
+ newBatch.splice(index, 1);
+ const newItemAtIndex = newBatch[index];
+ if (newItemAtIndex != null) setSelectedBatchFiles([newItemAtIndex.path]);
+ else if (newBatch.length > 0) setSelectedBatchFiles([newBatch[0].path]);
+ else setSelectedBatchFiles([]);
+ return newBatch;
+ });
}, []);
const cleanupFilesDialog = useCallback(async () => {