Skip to content

Commit

Permalink
fix(grids) Restore Metadata When Cancelling Interaction. (#6694)
Browse files Browse the repository at this point in the history
- `interactionCancel` now always restores the metadata regardless of the
state of the interaction session.
  • Loading branch information
seanparsons authored Dec 4, 2024
1 parent 6f299cf commit b8c8a71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('interactionCancel', () => {
'zero-drag-not-permitted',
),
)
const actualResult = interactionCancel(editorStore, dispatchResultFromEditorStore(editorStore))
const actualResult = interactionCancel(dispatchResultFromEditorStore(editorStore))
expect(actualResult.newStrategyState.commandDescriptions).toHaveLength(0)
expect(actualResult.newStrategyState.currentStrategyCommands).toHaveLength(0)
expect(actualResult.newStrategyState.currentStrategy).toBeNull()
Expand Down
16 changes: 5 additions & 11 deletions editor/src/components/editor/store/dispatch-strategies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,22 +407,16 @@ export function interactionStart(
}
}

export function interactionCancel(
storedState: EditorStoreFull,
result: EditorStoreUnpatched,
): HandleStrategiesResult {
const interactionWasInProgress = interactionInProgress(
storedState.unpatchedEditor.canvas.interactionSession,
)
export function interactionCancel(result: EditorStoreUnpatched): HandleStrategiesResult {
const updatedEditorState: EditorState = {
...result.unpatchedEditor,
canvas: {
...result.unpatchedEditor.canvas,
interactionSession: null,
},
jsxMetadata: interactionWasInProgress ? {} : result.unpatchedEditor.jsxMetadata,
domMetadata: interactionWasInProgress ? {} : result.unpatchedEditor.domMetadata,
spyMetadata: interactionWasInProgress ? {} : result.unpatchedEditor.spyMetadata,
jsxMetadata: result.unpatchedEditor.jsxMetadata,
domMetadata: result.unpatchedEditor.domMetadata,
spyMetadata: result.unpatchedEditor.spyMetadata,
}

return {
Expand Down Expand Up @@ -823,7 +817,7 @@ function handleStrategiesInner(
}
} else {
if (cancelInteraction) {
return interactionCancel(storedState, result)
return interactionCancel(result)
} else if (makeChangesPermanent) {
return interactionFinished(strategies, storedState, result)
} else {
Expand Down

0 comments on commit b8c8a71

Please sign in to comment.