Skip to content

Wizard: Work around FirstBoot editor losing keyboard focus (HMS-9956)#4003

Closed
ochosi wants to merge 1 commit intoosbuild:mainfrom
ochosi:HMS-9956
Closed

Wizard: Work around FirstBoot editor losing keyboard focus (HMS-9956)#4003
ochosi wants to merge 1 commit intoosbuild:mainfrom
ochosi:HMS-9956

Conversation

@ochosi
Copy link
Copy Markdown
Collaborator

@ochosi ochosi commented Jan 19, 2026

Intro

This is a possible workaround for an upstream bug in patternfly-react/CodeEditor. An upstream fix has been submitted (patternfly/patternfly-react#12212). In case we consider the bug too grave, we can consider this minimal patch as a workaround.

The downsides are that the EmptyState is broken by this workaround and not shown at all. It would be possible to alleviate that, but I've tried it and it results in rewriting portions of CodeEditor inside image-builder-frontend, so I would advise against it.


Bug

When typing the first character in the FirstBoot script editor, the Monaco editor would lose focus and cursor position, making typing impossible.

Root cause

PatternFly's CodeEditor uses conditional JSX rendering based on isUploadEnabled and whether code is empty. When code transitions from empty to non-empty, React unmounts and remounts the Monaco editor component, causing focus and cursor state to be lost.

The fix removes isUploadEnabled to prevent the JSX branch switch. This disables the "Browse" upload button but preserves copy, download, and "Start from scratch" functionality.

When typing the first character in the FirstBoot script editor, the
Monaco editor would lose focus and cursor position, making typing
impossible.

Root cause: PatternFly's CodeEditor uses conditional JSX rendering
based on `isUploadEnabled` and whether `code` is empty. When code
transitions from empty to non-empty, React unmounts and remounts the
Monaco editor component, causing focus and cursor state to be lost.

The fix removes `isUploadEnabled` to prevent the JSX branch switch.
This disables the "Browse" upload button but preserves copy, download,
and "Start from scratch" functionality.
@ochosi ochosi requested a review from a team as a code owner January 19, 2026 13:32
@ochosi ochosi requested review from kingsleyzissou, regexowl and tkoscieln and removed request for a team January 19, 2026 13:32
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Since this is a temporary workaround for an upstream bug, consider adding an inline comment next to the CodeEditor props (with a link to the upstream PR) explaining why isUploadEnabled and emptyStateButton are intentionally omitted so future maintainers know when it’s safe to revert.
  • If this focus issue may appear in other CodeEditor usages, consider wrapping CodeEditor in a small local wrapper component that encapsulates this workaround, so the behavior is consistent and the hack is centralized rather than being applied ad hoc in individual steps.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since this is a temporary workaround for an upstream bug, consider adding an inline comment next to the `CodeEditor` props (with a link to the upstream PR) explaining why `isUploadEnabled` and `emptyStateButton` are intentionally omitted so future maintainers know when it’s safe to revert.
- If this focus issue may appear in other CodeEditor usages, consider wrapping CodeEditor in a small local wrapper component that encapsulates this workaround, so the behavior is consistent and the hack is centralized rather than being applied ad hoc in individual steps.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

The FirstBoot component in the CreateImageWizard updates the CodeEditor configuration. The isUploadEnabled prop is removed, disabling script uploads. The isDownloadEnabled prop is retained, maintaining download functionality. A new isCopyEnabled prop is added to enable copy operations. Additionally, the empty state control transitions from a "Browse" button to a "Start from scratch" link. These modifications result in a net change of one line added and three lines removed.


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.

@ochosi ochosi changed the title Wizard: Fix FirstBoot editor losing keyboard focus (HMS-9956) Wizard: Work around FirstBoot editor losing keyboard focus (HMS-9956) Jan 19, 2026
@ochosi
Copy link
Copy Markdown
Collaborator Author

ochosi commented Jan 27, 2026

My upstream PatternFly fix got merged, so let's close this and pull in the latest version of patternfly-react as soon as it's released.

1 similar comment
@ochosi
Copy link
Copy Markdown
Collaborator Author

ochosi commented Jan 27, 2026

My upstream PatternFly fix got merged, so let's close this and pull in the latest version of patternfly-react as soon as it's released.

@ochosi ochosi closed this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant