From 82ca390bf445f52200500dec34d5f9b5d821c434 Mon Sep 17 00:00:00 2001 From: jelveh Date: Fri, 7 Aug 2026 08:49:13 -0700 Subject: [PATCH] fix(gui): create-in-folder via sidebar right-click renders in target dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right-clicking a sidebar/breadcrumb folder in the dashboard Files tab and choosing New > Folder (or any file type) created the item in the right- clicked folder correctly, but the UI inserted the new row and started the inline rename in whatever directory was currently open — so the item appeared to be created in the wrong place until a refresh. Now, when the creation target isn't the directory on screen, navigate to the target and run the select + rename flow there; same-directory creation keeps the incremental insert. --- src/gui/src/UI/Dashboard/TabFiles.js | 50 ++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/gui/src/UI/Dashboard/TabFiles.js b/src/gui/src/UI/Dashboard/TabFiles.js index 21425f4b1..5c9733731 100644 --- a/src/gui/src/UI/Dashboard/TabFiles.js +++ b/src/gui/src/UI/Dashboard/TabFiles.js @@ -3794,15 +3794,27 @@ const TabFiles = { rename: true, overwrite: false, }); - // Remove empty-directory placeholder if present - _this.$el_window.find('.files-tab .files > div:not(.item)').remove(); - // Add the new folder incrementally - await _this.renderItem(result); + if ( targetPath === _this.currentPath ) { + // Remove empty-directory placeholder if present + _this.$el_window.find('.files-tab .files > div:not(.item)').remove(); + // Add the new folder incrementally + await _this.renderItem(result); + const $newRow = _this.$el_window.find(`.files-tab .files .item[data-uid='${result.uid}']`); + if ( $newRow.length > 0 ) { + _this.insertAtSortedPosition($newRow, result); + _this.applyColumnWidths(); + _this.updateFooterStats(); + } + } else { + // Created via a sidebar/breadcrumb right-click on a + // folder that isn't the one on screen — navigate to + // it so the rename happens where the folder lives, + // not as a phantom row in the current listing. + _this.pushNavHistory(targetPath); + await _this.renderDirectory(targetPath, { consistency: 'strong' }); + } const $newRow = _this.$el_window.find(`.files-tab .files .item[data-uid='${result.uid}']`); if ( $newRow.length > 0 ) { - _this.insertAtSortedPosition($newRow, result); - _this.applyColumnWidths(); - _this.updateFooterStats(); $newRow.addClass('selected'); window.activate_item_name_editor($newRow[0]); } @@ -3839,15 +3851,25 @@ const TabFiles = { if ( uploadPromise ) { const result = await uploadPromise; - // Remove empty-directory placeholder if present - _this.$el_window.find('.files-tab .files > div:not(.item)').remove(); - // Add the new file incrementally - await _this.renderItem(result); + if ( targetPath === _this.currentPath ) { + // Remove empty-directory placeholder if present + _this.$el_window.find('.files-tab .files > div:not(.item)').remove(); + // Add the new file incrementally + await _this.renderItem(result); + const $newRow = _this.$el_window.find(`.files-tab .files .item[data-uid='${result.uid}']`); + if ( $newRow.length > 0 ) { + _this.insertAtSortedPosition($newRow, result); + _this.applyColumnWidths(); + _this.updateFooterStats(); + } + } else { + // Same navigate-to-target treatment as New + // Folder above. + _this.pushNavHistory(targetPath); + await _this.renderDirectory(targetPath, { consistency: 'strong' }); + } const $newRow = _this.$el_window.find(`.files-tab .files .item[data-uid='${result.uid}']`); if ( $newRow.length > 0 ) { - _this.insertAtSortedPosition($newRow, result); - _this.applyColumnWidths(); - _this.updateFooterStats(); $newRow.addClass('selected'); window.activate_item_name_editor($newRow[0]); }