Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix fontFamily state updating (#1679)

David Luzar0db7ac78c41e
diff --git a/src/actions/actionProperties.tsx b/src/actions/actionProperties.tsx
index e56ffc10af..72f2ffb6ed 100644
--- a/src/actions/actionProperties.tsx
+++ b/src/actions/actionProperties.tsx
@@ -374,7 +374,7 @@ export const actionChangeFontFamily = register({
}),
appState: {
...appState,
- currentItemFontFamily: appState.currentItemFontFamily,
+ currentItemFontFamily: value,
},
commitToHistory: true,
};
diff --git a/src/tests/__snapshots__/regressionTests.test.tsx.snap b/src/tests/__snapshots__/regressionTests.test.tsx.snap
index 748a2bb4ac..b6afadd1dd 100644
--- a/src/tests/__snapshots__/regressionTests.test.tsx.snap
+++ b/src/tests/__snapshots__/regressionTests.test.tsx.snap
@@ -15677,6 +15677,75 @@ exports[`regression tests undo/redo drawing an element: [end of test] number of
exports[`regression tests undo/redo drawing an element: [end of test] number of renders 1`] = `24`;
+exports[`regression tests updates fontSize & fontFamily appState: [end of test] appState 1`] = `
+Object {
+ "collaborators": Map {},
+ "currentItemBackgroundColor": "transparent",
+ "currentItemFillStyle": "hachure",
+ "currentItemFontFamily": 3,
+ "currentItemFontSize": 20,
+ "currentItemOpacity": 100,
+ "currentItemRoughness": 1,
+ "currentItemStrokeColor": "#000000",
+ "currentItemStrokeStyle": "solid",
+ "currentItemStrokeWidth": 1,
+ "currentItemTextAlign": "left",
+ "cursorButton": "up",
+ "cursorX": 0,
+ "cursorY": 0,
+ "draggingElement": null,
+ "editingElement": null,
+ "editingGroupId": null,
+ "elementLocked": false,
+ "elementType": "text",
+ "errorMessage": null,
+ "exportBackground": true,
+ "isCollaborating": false,
+ "isLoading": false,
+ "isResizing": false,
+ "isRotating": false,
+ "lastPointerDownWith": "mouse",
+ "multiElement": null,
+ "name": "Unbenannt-201933152653",
+ "openMenu": null,
+ "resizingElement": null,
+ "scrollX": 0,
+ "scrollY": 0,
+ "scrolledOutside": false,
+ "selectedElementIds": Object {},
+ "selectedGroupIds": Object {},
+ "selectionElement": null,
+ "shouldAddWatermark": false,
+ "shouldCacheIgnoreZoom": false,
+ "showShortcutsDialog": false,
+ "username": "",
+ "viewBackgroundColor": "#ffffff",
+ "zenModeEnabled": false,
+ "zoom": 1,
+}
+`;
+
+exports[`regression tests updates fontSize & fontFamily appState: [end of test] history 1`] = `
+Object {
+ "recording": false,
+ "redoStack": Array [],
+ "stateHistory": Array [
+ Object {
+ "appState": Object {
+ "name": "Unbenannt-201933152653",
+ "selectedElementIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [],
+ },
+ ],
+}
+`;
+
+exports[`regression tests updates fontSize & fontFamily appState: [end of test] number of elements 1`] = `0`;
+
+exports[`regression tests updates fontSize & fontFamily appState: [end of test] number of renders 1`] = `4`;
+
exports[`regression tests zoom hotkeys: [end of test] appState 1`] = `
Object {
"collaborators": Map {},
diff --git a/src/tests/queries/toolQueries.ts b/src/tests/queries/toolQueries.ts
index a106e573aa..6c18045a69 100644
--- a/src/tests/queries/toolQueries.ts
+++ b/src/tests/queries/toolQueries.ts
@@ -8,6 +8,7 @@ const toolMap = {
arrow: "arrow",
line: "line",
draw: "draw",
+ text: "text",
};
export type ToolName = keyof typeof toolMap;
diff --git a/src/tests/regressionTests.test.tsx b/src/tests/regressionTests.test.tsx
index bad6ac1ac9..b369cd3645 100644
--- a/src/tests/regressionTests.test.tsx
+++ b/src/tests/regressionTests.test.tsx
@@ -840,4 +840,11 @@ describe("regression tests", () => {
mouse.doubleClick();
expect(getSelectedElements().length).toBe(1);
});
+
+ it("updates fontSize & fontFamily appState", () => {
+ clickTool("text");
+ expect(h.state.currentItemFontFamily).toEqual(1); // Virgil
+ fireEvent.click(screen.getByText(/code/i));
+ expect(h.state.currentItemFontFamily).toEqual(3); // Cascadia
+ });
});