From 95f45106245bfe0369ed86cc0528d121e954b05c Mon Sep 17 00:00:00 2001 From: Hiroki Goto Date: Sat, 6 Apr 2024 08:25:13 +0000 Subject: [PATCH] fix: Prevent onChange from firing when updating value in readOnly mode (#504) --- src/Editor/Editor.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Editor/Editor.tsx b/src/Editor/Editor.tsx index 59b93d8..3afbb22 100644 --- a/src/Editor/Editor.tsx +++ b/src/Editor/Editor.tsx @@ -96,7 +96,9 @@ function Editor({ () => { if (!editorRef.current || value === undefined) return; if (editorRef.current.getOption(monacoRef.current!.editor.EditorOption.readOnly)) { + preventTriggerChangeEvent.current = true; editorRef.current.setValue(value); + preventTriggerChangeEvent.current = false; } else if (value !== editorRef.current.getValue()) { preventTriggerChangeEvent.current = true; editorRef.current.executeEdits('', [