mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-28 17:07:16 +00:00
fix(gui): create-in-folder via sidebar right-click renders in target dir
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.
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user