diff --git a/src/gui/src/UI/Dashboard/UIDashboard.js b/src/gui/src/UI/Dashboard/UIDashboard.js index c3537b813..0dddb95cf 100644 --- a/src/gui/src/UI/Dashboard/UIDashboard.js +++ b/src/gui/src/UI/Dashboard/UIDashboard.js @@ -266,10 +266,17 @@ async function UIDashboard (options) { window.socket.on('item.moved', async (resp) => { if ( resp.original_client_socket_id === window.socket.id ) return; - // Fade out old item from view - $(`.item[data-uid='${resp.uid}']`).fadeOut(150, function () { - $(this).remove(); - }); + // Fade out the stale row at the item's OLD location only. A moved item + // keeps its uid, so removing by uid would also match the row at the new + // location — and when the destination is the directory currently in + // view (e.g. after spring-loading a folder open mid-drag), that deletes + // the freshly-added row instead of the stale one. + const old_path = resp.old_path ?? resp.from_path; + if ( old_path ) { + $(`.item[data-path='${html_encode(old_path)}']`).fadeOut(150, function () { + $(this).remove(); + }); + } // Create new item at destination if user is viewing that directory if ( window.UIDashboardFileItem ) { diff --git a/src/gui/src/helpers.js b/src/gui/src/helpers.js index 37963381c..ce6c1fc3e 100644 --- a/src/gui/src/helpers.js +++ b/src/gui/src/helpers.js @@ -1817,8 +1817,12 @@ window.move_items = async function (el_items, dest_path, is_undo = false) { // update all shortcut_to_path $(`.item[data-shortcut_to_path="${html_encode($(el_item).attr('data-path'))}" i]`).attr('data-shortcut_to_path', fsentry.path); - // Remove all items with matching uids - $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).fadeOut(150, function () { + // Remove all items with matching uids from their OLD location(s). + // Exclude any row already at the item's new path: a concurrent + // item.moved socket handler may have just created a row at the + // destination (e.g. the dashboard file view showing the target + // directory), and removing by uid alone would delete it too. + $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).not(`[data-path="${html_encode(fsentry.path)}" i]`).fadeOut(150, function () { // find all parent windows that contain this item let parent_windows = $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).closest('.window'); // remove this item