Skip to content

Conversation

@ochosi
Copy link
Contributor

@ochosi ochosi commented Jan 18, 2026

Problem

When using CodeEditor with isUploadEnabled={true}, typing the first character causes the Monaco editor to lose focus and cursor position.

Solution

Remove && !value from the outer conditional at line 599. The outer branch should only depend on whether upload/emptyState features are enabled, not on current code content. The inner condition already handles empty state display correctly.

I have verified the fix locally by running image-builder-frontend linked against the patched patternfly-react.

What: Closes #12211

Additional issues: https://issues.redhat.com/browse/HMS-9956 (Bug surfacing in Image Builder)

Summary by CodeRabbit

  • Style

    • Improved editor container visuals and consistent styling across upload-enabled, empty, loading, and populated states.
  • Refactor

    • Unified component layout and simplified render structure so the editor uses a consistent container and internal sections in all states.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

Walkthrough

Modified CodeEditor rendering so the upload/dropzone container remains stable when isUploadEnabled or emptyState is true by removing the && !value requirement from the outer conditional; both branches now render a consistent codeEditorContainer wrapper to avoid remounts and focus loss.

Changes

Cohort / File(s) Summary
CodeEditor rendering fix
packages/react-code-editor/src/components/CodeEditor/CodeEditor.tsx
Outer conditional changed from `(isUploadEnabled

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main fix: preventing focus loss in CodeEditor, which is the core issue addressed by removing the && !value condition.
Linked Issues check ✅ Passed The code changes directly address all primary objectives: removing && !value from the outer conditional prevents Monaco editor remounting, maintaining focus and cursor position during the empty→non-empty transition.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the focus loss issue by restructuring the conditional wrapper and updating container logic as described in issue #12211, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Remove `&& !value` from outer conditional rendering to prevent Monaco
editor from unmounting when code transitions from empty to non-empty.
@ochosi ochosi force-pushed the code-editor-fix-focus-loss branch from 8fcbdaa to d5f768b Compare January 18, 2026 01:58
@patternfly-build
Copy link
Collaborator

patternfly-build commented Jan 18, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - CodeEditor - Loses focus and cursor position when typing first character with isUploadEnabled

2 participants