mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: decouple actionFinalize and actionErase (#4984)
* Update actionCanvas.tsx * Update actionFinalize.tsx * lint * remove Escape trigger from actionErase * revert to lastActiveTool only if coming from eraser tool * unrelated: fix restoring `appState.activeTool` * one more restoring fix * fix tests Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
f2d2f97546
commit
734bb4d2ed
4 changed files with 22 additions and 16 deletions
|
@ -14,7 +14,6 @@ import {
|
|||
bindOrUnbindLinearElement,
|
||||
} from "../element/binding";
|
||||
import { isBindingElement } from "../element/typeChecks";
|
||||
import { isEraserActive } from "../appState";
|
||||
|
||||
export const actionFinalize = register({
|
||||
name: "finalize",
|
||||
|
@ -146,7 +145,14 @@ export const actionFinalize = register({
|
|||
appState.activeTool.type === "freedraw") &&
|
||||
multiPointElement
|
||||
? appState.activeTool
|
||||
: { ...appState.activeTool, type: "selection" },
|
||||
: {
|
||||
...appState.activeTool,
|
||||
type:
|
||||
appState.activeTool.type === "eraser" &&
|
||||
appState.activeTool.lastActiveToolBeforeEraser
|
||||
? appState.activeTool.lastActiveToolBeforeEraser
|
||||
: "selection",
|
||||
},
|
||||
draggingElement: null,
|
||||
multiElement: null,
|
||||
editingElement: null,
|
||||
|
@ -167,12 +173,11 @@ export const actionFinalize = register({
|
|||
};
|
||||
},
|
||||
keyTest: (event, appState) =>
|
||||
!isEraserActive(appState) &&
|
||||
((event.key === KEYS.ESCAPE &&
|
||||
(event.key === KEYS.ESCAPE &&
|
||||
(appState.editingLinearElement !== null ||
|
||||
(!appState.draggingElement && appState.multiElement === null))) ||
|
||||
((event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) &&
|
||||
appState.multiElement !== null)),
|
||||
((event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) &&
|
||||
appState.multiElement !== null),
|
||||
PanelComponent: ({ appState, updateData, data }) => (
|
||||
<ToolButton
|
||||
type="button"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue