Skip to content

Commit 9860463

Browse files
committed
fix: stabilize onChange handler and enforce strict theme derivation
Signed-off-by: tirth707 <ptirth2206@gmail.com>
1 parent fb8965e commit 9860463

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/editors/ConcertoEditor.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMonaco } from "@monaco-editor/react";
2-
import { lazy, Suspense, useEffect, useMemo, useRef } from "react";
2+
import { lazy, Suspense, useEffect, useMemo, useRef, useCallback } from "react";
33
import * as monaco from "monaco-editor";
44
import useAppStore from "../store/store";
55
import { shallow } from "zustand/shallow";
@@ -108,6 +108,13 @@ export default function ConcertoEditor({ value, onChange }: ConcertoEditorProps)
108108
[backgroundColor]
109109
);
110110

111+
const handleChange = useCallback(
112+
(val: string | undefined) => {
113+
onChange?.(val);
114+
},
115+
[onChange]
116+
);
117+
111118
const options: monaco.editor.IStandaloneEditorConstructionOptions = useMemo(() => ({
112119
minimap: { enabled: false },
113120
wordWrap: "on",
@@ -189,7 +196,7 @@ export default function ConcertoEditor({ value, onChange }: ConcertoEditorProps)
189196
value={value}
190197
beforeMount={handleEditorWillMount}
191198
onMount={handleEditorDidMount}
192-
onChange={(val) => onChange?.(val)}
199+
onChange={handleChange}
193200
theme={themeName}
194201
/>
195202
</Suspense>

0 commit comments

Comments
 (0)