Skip to content

Commit

Permalink
Merge pull request #13541 from openshift-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-13510-to-release-4.14

[release-4.14] OCPBUGS-29813: Addition of optional chaining to prevent yaml crash
  • Loading branch information
openshift-merge-bot[bot] committed Mar 4, 2024
2 parents c5c6009 + 4f8ffc2 commit 773c6d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 773c6d9

Please sign in to comment.