Skip to content

Commit

Permalink
absorb: only track absorb history on drag-n-drop success
Browse files Browse the repository at this point in the history
Summary:
Dragging can fail because of invalid drop targets. Ensure the undo history only
tracks successful DnDs.

Reviewed By: evangrayk

Differential Revision: D67927312

fbshipit-source-id: 472f902581384d99e10770a25bc9ba565ee54ea0
  • Loading branch information
quark-zju authored and facebook-github-bot committed Jan 8, 2025
1 parent f136db1 commit 9d19d8f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions addons/isl/src/stackEdit/ui/AbsorbStackEditPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ function SingleAbsorbEdit(props: {edit: AbsorbEdit; inDraggingOverlay?: boolean}
try {
newStack = stack.setAbsorbEditDestination(fileStackIndex, absorbEditId, rev);
writeAtom(draggingHint, null);
// `handleDrag` won't be updated with "refreshed" `stackEdit`.
// So `push` can work like `replaceTopOperation` while dragging.
stackEdit.push(newStack, {name: 'absorbMove', commit});
} catch {
writeAtom(
draggingHint,
Expand All @@ -326,11 +329,6 @@ function SingleAbsorbEdit(props: {edit: AbsorbEdit; inDraggingOverlay?: boolean}
),
);
}
if (isDragging == null) {
stackEdit.push(newStack, {name: 'absorbMove', commit});
} else {
stackEdit.replaceTopOperation(newStack, {name: 'absorbMove', commit});
}
}
} else {
// Ensure the hint is cleared when not dragging.
Expand Down

0 comments on commit 9d19d8f

Please sign in to comment.