From 64e2af8f2c735c76102f51ab18171390f4195c5c Mon Sep 17 00:00:00 2001 From: Kumar Aditya Raj Date: Thu, 12 Nov 2026 13:37:20 +0530 Subject: [PATCH 1/8] Handling blank canvas Signed-off-by: Kumar Aditya Raj --- .../dual-editor/tests/DualEditor.test.tsx | 26 +++++++---- .../src/diagram-editor/DiagramEditor.tsx | 28 +++++++++++- .../src/i18n/locales/en.ts | 3 ++ .../src/store/DiagramEditorContext.tsx | 2 + .../store/DiagramEditorContextProvider.tsx | 6 +++ .../src/styles.css | 30 +++++++++++++ .../diagram-editor/DiagramEditor.test.tsx | 44 +++++++++++++++++++ .../tests/test-utils/render-helpers.tsx | 1 + 8 files changed, 129 insertions(+), 11 deletions(-) diff --git a/packages/dual-editor/tests/DualEditor.test.tsx b/packages/dual-editor/tests/DualEditor.test.tsx index 70c075f4..42a5b81a 100644 --- a/packages/dual-editor/tests/DualEditor.test.tsx +++ b/packages/dual-editor/tests/DualEditor.test.tsx @@ -15,7 +15,7 @@ */ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"; -import { useEffect, useState } from "react"; +import { useEffect, useRef } from "react"; import type { ComponentProps } from "react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { DualEditor } from "../src/DualEditor"; @@ -28,17 +28,21 @@ vi.mock("@openworkflowspec/text-editor", () => ({ content: string; onContentChange?: (content: string) => void; }) => { - const [editorContent, setEditorContent] = useState(content); - useEffect(() => setEditorContent(content), [content]); + const textareaRef = useRef(null); + useEffect(() => { + if (textareaRef.current && textareaRef.current.value !== content) { + textareaRef.current.value = content; + } + }, [content]); return (