Skip to content

Commit 8fcbdaa

Browse files
committed
fix(CodeEditor): prevent focus loss (#12211)
Remove `&& !value` from outer conditional rendering to prevent Monaco editor from unmounting when code transitions from empty to non-empty.
1 parent 884ad17 commit 8fcbdaa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react-code-editor/src/components/CodeEditor/CodeEditor.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ export const CodeEditor = ({
596596
)}
597597
ref={ref}
598598
>
599-
{(isUploadEnabled || emptyState) && !value ? (
599+
{(isUploadEnabled || emptyState) ? (
600+
/* Upload/EmptyState enabled: wrap in Dropzone container */
600601
<div
601602
{...getRootProps({
602603
onClick: (event) => event.stopPropagation() // Prevents clicking TextArea from opening file dialog
@@ -619,15 +620,16 @@ export const CodeEditor = ({
619620
</div>
620621
</div>
621622
) : (
622-
<>
623+
/* No upload/emptyState: use consistent container structure */
624+
<div className={css(styles.codeEditorContainer)}>
623625
{editorHeader}
624626
{showEditor && (
625627
<div className={css(styles.codeEditorMain)}>
626628
{hiddenFileInput}
627629
{editor}
628630
</div>
629631
)}
630-
</>
632+
</div>
631633
)}
632634
</div>
633635
);

0 commit comments

Comments
 (0)