diff --git a/packages/amis-editor/src/renderer/FormulaControl.tsx b/packages/amis-editor/src/renderer/FormulaControl.tsx index 27914cba9..43c26ea86 100644 --- a/packages/amis-editor/src/renderer/FormulaControl.tsx +++ b/packages/amis-editor/src/renderer/FormulaControl.tsx @@ -250,7 +250,7 @@ export default class FormulaControl extends React.Component< this.props ); const rawType = - utils.RAW_TYPE_MAP[rendererSchema.type as SchemaType] || 'string'; + utils.RAW_TYPE_MAP[rendererSchema?.type as SchemaType] || 'string'; const filterVars = variables .map(item => { if (item.children && item.type !== 'quickVars') { diff --git a/packages/amis-ui/src/components/CodeMirror.tsx b/packages/amis-ui/src/components/CodeMirror.tsx index fbf8afab7..9ee4bbcb4 100644 --- a/packages/amis-ui/src/components/CodeMirror.tsx +++ b/packages/amis-ui/src/components/CodeMirror.tsx @@ -48,7 +48,8 @@ export class CodeMirrorEditor extends React.Component { this.props.editorFactory?.(this.dom.current!, cm, this.props) ?? cm(this.dom.current!, { value: this.props.value || '', - readOnly: this.props.readOnly ? 'nocursor' : false + readOnly: this.props.readOnly ? 'nocursor' : false, + autofocus: false }); this.props.editorDidMount?.(cm, this.editor); @@ -56,7 +57,7 @@ export class CodeMirrorEditor extends React.Component { this.editor.on('blur', this.handleBlur); this.editor.on('focus', this.handleFocus); - this.setValue(this.props.value); + this.props.value && this.setValue(this.props.value); this.toDispose.push( resizeSensor(this.dom.current as HTMLElement, () =>