fix: update cursorButton once freedraw is released (#4996)

Co-authored-by: dwelle <luzar.david@gmail.com>
pull/5002/head
Valerii Gusev 3 years ago committed by GitHub
parent 9ba7ca3845
commit 880e4feede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -39,6 +39,7 @@ export const actionFinalize = register({
: undefined, : undefined,
appState: { appState: {
...appState, ...appState,
cursorButton: "up",
editingLinearElement: null, editingLinearElement: null,
}, },
commitToHistory: true, commitToHistory: true,
@ -140,6 +141,7 @@ export const actionFinalize = register({
elements: newElements, elements: newElements,
appState: { appState: {
...appState, ...appState,
cursorButton: "up",
activeTool: activeTool:
(appState.activeTool.locked || (appState.activeTool.locked ||
appState.activeTool.type === "freedraw") && appState.activeTool.type === "freedraw") &&

@ -252,6 +252,7 @@ export const restoreAppState = (
} }
return { return {
...nextAppState, ...nextAppState,
cursorButton: localAppState?.cursorButton || "up",
// reset on fresh restore so as to hide the UI button if penMode not active // reset on fresh restore so as to hide the UI button if penMode not active
penDetected: penDetected:
localAppState?.penDetected ?? localAppState?.penDetected ??

@ -6729,7 +6729,7 @@ Object {
"currentItemStrokeStyle": "solid", "currentItemStrokeStyle": "solid",
"currentItemStrokeWidth": 1, "currentItemStrokeWidth": 1,
"currentItemTextAlign": "left", "currentItemTextAlign": "left",
"cursorButton": "down", "cursorButton": "up",
"draggingElement": null, "draggingElement": null,
"editingElement": null, "editingElement": null,
"editingGroupId": null, "editingGroupId": null,
@ -11029,7 +11029,7 @@ Object {
"currentItemStrokeStyle": "solid", "currentItemStrokeStyle": "solid",
"currentItemStrokeWidth": 1, "currentItemStrokeWidth": 1,
"currentItemTextAlign": "left", "currentItemTextAlign": "left",
"cursorButton": "down", "cursorButton": "up",
"draggingElement": null, "draggingElement": null,
"editingElement": null, "editingElement": null,
"editingGroupId": null, "editingGroupId": null,
@ -12181,7 +12181,7 @@ Object {
"currentItemStrokeStyle": "solid", "currentItemStrokeStyle": "solid",
"currentItemStrokeWidth": 1, "currentItemStrokeWidth": 1,
"currentItemTextAlign": "left", "currentItemTextAlign": "left",
"cursorButton": "down", "cursorButton": "up",
"draggingElement": null, "draggingElement": null,
"editingElement": null, "editingElement": null,
"editingGroupId": null, "editingGroupId": null,

@ -313,9 +313,7 @@ describe("restoreAppState", () => {
expect(restoredAppState.activeTool).toEqual( expect(restoredAppState.activeTool).toEqual(
stubImportedAppState.activeTool, stubImportedAppState.activeTool,
); );
expect(restoredAppState.cursorButton).toBe( expect(restoredAppState.cursorButton).toBe("up");
stubImportedAppState.cursorButton,
);
expect(restoredAppState.name).toBe(stubImportedAppState.name); expect(restoredAppState.name).toBe(stubImportedAppState.name);
}); });
@ -347,9 +345,7 @@ describe("restoreAppState", () => {
stubImportedAppState, stubImportedAppState,
null, null,
); );
expect(restoredAppState.cursorButton).toBe( expect(restoredAppState.cursorButton).toBe("up");
stubImportedAppState.cursorButton,
);
expect(restoredAppState.name).toBe(stubImportedAppState.name); expect(restoredAppState.name).toBe(stubImportedAppState.name);
}); });
@ -502,9 +498,7 @@ describe("restore", () => {
importedDataState.appState = stubImportedAppState; importedDataState.appState = stubImportedAppState;
const restoredData = restore.restore(importedDataState, null, null); const restoredData = restore.restore(importedDataState, null, null);
expect(restoredData.appState.cursorButton).toBe( expect(restoredData.appState.cursorButton).toBe("up");
stubImportedAppState.cursorButton,
);
expect(restoredData.appState.name).toBe(stubImportedAppState.name); expect(restoredData.appState.name).toBe(stubImportedAppState.name);
}); });

Loading…
Cancel
Save