From dbfd75e7ffa50d694c450808b0fd285e48bbfb41 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 18:44:34 -0300 Subject: [PATCH] fix: close sidebar when deleting the selected file - Changed condition from checking 'uuid' to 'nodeId' in delete method - Added logic to close sidebar when the deleted file is the currently selected one - Simplified deleteMultiple method to rely on delete method's cleanup This fixes the issue where the sidebar remained open after deleting the only/selected file, both when the file was just uploaded or when the page was already loaded. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/store/files.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/store/files.js b/src/store/files.js index 990d576f0..11d3ac23f 100644 --- a/src/store/files.js +++ b/src/store/files.js @@ -254,7 +254,7 @@ export const useFilesStore = function(...args) { }, async delete(file, deleteFile) { file = this.getFile(file) - if (file?.uuid !== undefined) { + if (file?.nodeId) { const url = deleteFile ? '/apps/libresign/api/v1/file/file_id/{fileId}' : '/apps/libresign/api/v1/sign/file_id/{fileId}' @@ -262,6 +262,11 @@ export const useFilesStore = function(...args) { fileId: file.nodeId, })) .then(() => { + if (this.selectedNodeId === file.nodeId) { + const sidebarStore = useSidebarStore() + sidebarStore.hideSidebar() + this.selectedNodeId = 0 + } del(this.files, file.nodeId) const index = this.ordered.indexOf(file.nodeId) if (index > -1) { @@ -273,11 +278,9 @@ export const useFilesStore = function(...args) { }, async deleteMultiple(nodeIds, deleteFile) { this.loading = true - nodeIds.forEach(async nodeId => { + for (const nodeId of nodeIds) { await this.delete(this.files[nodeId], deleteFile) - }) - const toRemove = nodeIds.filter(nodeId => (!this.files[nodeId]?.uuid)) - del(this.files, ...toRemove) + } this.loading = false }, async upload({ file, name }) {