From d083d108c8cec8ce6e58f374d9ff39237169c185 Mon Sep 17 00:00:00 2001 From: DmitrySychugov Date: Mon, 10 Jun 2024 16:35:12 +0500 Subject: [PATCH] Client: fixed onMouseUp indexing change logic --- packages/client/src/pages/Home/Section/Body/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/client/src/pages/Home/Section/Body/index.js b/packages/client/src/pages/Home/Section/Body/index.js index b0f64b4359..57f643a075 100644 --- a/packages/client/src/pages/Home/Section/Body/index.js +++ b/packages/client/src/pages/Home/Section/Body/index.js @@ -315,7 +315,8 @@ const SectionBodyContent = (props) => { const replaceableItemType = value && value.split("_").slice(0, 1).join("_"); const isSectionTarget = elem && elem.className === sectionClass; - const replaceableItem = isSectionTarget + let replaceable; + const item = isSectionTarget ? filesList[filesList.length - 1] : filesList.find((i) => replaceableItemType === "file" @@ -323,9 +324,14 @@ const SectionBodyContent = (props) => { : i.id === replaceableItemId, ); - if (!replaceableItem) return; + replaceable = item; + if (item === filesList[filesList.length - 1] && !isSectionTarget) { + replaceable = filesList[filesList.length - 2]; + } - changeIndex(VDRIndexingAction.MoveIndex, replaceableItem); + if (!replaceable) return; + + changeIndex(VDRIndexingAction.MoveIndex, replaceable); return; };