Skip to content

Commit

Permalink
wip fix ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed Aug 11, 2021
1 parent 668a048 commit 4fa425a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,21 @@ export default function ListView( {
if ( ! lastTarget.current ) {
return;
}
const targetId = lastTarget.current.targetPosition.clientId;
const clientId = lastTarget.current.clientId;
const target = findCurrentPosition( clientIdsTree, targetId );
const current = findCurrentPosition(
clientIdsTree,
lastTarget.clientId
const { targetPosition, clientId, movingDown } = lastTarget.current;
const targetId = targetPosition.clientId;
const target = findCurrentPosition(
removeItemFromTree( clientIdsTree, clientId ),
targetId
);
const current = findCurrentPosition( clientIdsTree, clientId );

const targetIndex = movingDown ? target.index + 1 : target.index;
setDropped( true );
moveBlocksToPosition(
[ clientId ],
current.parentId,
target.parentId,
target.index
targetIndex
);
lastTarget.current = null;
//TODO: see if waiting for the state update hides unecessary layout changes.
Expand All @@ -237,6 +239,7 @@ export default function ListView( {
lastTarget.current = {
clientId,
targetPosition,
movingDown,
};
const newTree = addItemToTree(
removeItemFromTree( clientIdsTree, clientId ),
Expand Down

0 comments on commit 4fa425a

Please sign in to comment.