Skip to content

Commit

Permalink
fix: Prevent onChange from firing when updating value in readOnly mode (
Browse files Browse the repository at this point in the history
  • Loading branch information
togo5 committed Apr 6, 2024
1 parent 3327f3c commit 95f4510
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('', [
Expand Down

0 comments on commit 95f4510

Please sign in to comment.