Skip to content

Commit 9e8570d

Browse files
Merge pull request #13510 from sg00dwin/additional-yaml-editor-crash-fix
OCPBUGS-16736: Addition of optional chaining to prevent yaml crash
2 parents c05d133 + 3e66d20 commit 9e8570d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

frontend/packages/console-shared/src/components/editor/CodeEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CodeEditor = React.forwardRef<MonacoEditor, CodeEditorProps>((props, ref)
2424
const [usesValue] = React.useState<boolean>(value !== undefined);
2525
const editorDidMount = React.useCallback(
2626
(editor, monaco) => {
27-
const currentLanguage = editor.getModel().getModeId();
27+
const currentLanguage = editor.getModel()?.getModeId();
2828
editor.layout();
2929
editor.focus();
3030
switch (currentLanguage) {

frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ const MODEL_URI = 'inmemory://model.yaml';
1616
const MONACO_URI = monaco.Uri.parse(MODEL_URI);
1717

1818
const createDocument = (model) => {
19-
return TextDocument.create(MODEL_URI, model.getModeId(), model.getVersionId(), model.getValue());
19+
return TextDocument.create(
20+
MODEL_URI,
21+
model?.getModeId(),
22+
model?.getVersionId(),
23+
model?.getValue(),
24+
);
2025
};
2126

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

0 commit comments

Comments
 (0)