Skip to content

Commit

Permalink
Merge pull request #13638 from sg00dwin/release-4.15
Browse files Browse the repository at this point in the history
OCPBUGS-29812: Changes to prevent yaml editor crash in version 4.15
  • Loading branch information
openshift-merge-bot[bot] committed Mar 6, 2024
2 parents a45aa76 + 56c2d54 commit 8dfeef7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -24,7 +24,7 @@ const CodeEditor = React.forwardRef<MonacoEditor, CodeEditorProps>((props, ref)
const [usesValue] = React.useState<boolean>(value !== undefined);
const editorDidMount = React.useCallback(
(editor, monaco) => {
const currentLanguage = editor.getModel().getModeId();
const currentLanguage = editor.getModel()?.getModeId();
editor.layout();
editor.focus();
switch (currentLanguage) {
Expand Down
Expand Up @@ -16,7 +16,12 @@ const MODEL_URI = 'inmemory://model.yaml';
const MONACO_URI = monaco.Uri.parse(MODEL_URI);

const createDocument = (model) => {
return TextDocument.create(MODEL_URI, model.getModeId(), model.getVersionId(), model.getValue());
return TextDocument.create(
MODEL_URI,
model?.getModeId(),
model?.getVersionId(),
model?.getValue(),
);
};

// Unfortunately, `editor.focus()` doesn't work when hiding the shortcuts
Expand Down

0 comments on commit 8dfeef7

Please sign in to comment.