Skip to content

Commit bae2fe5

Browse files
authored
feat(ui): allow customizing min height of code editor (#9920)
Requirement for #9645. Dynamic code field resizing currently is broken for line-breaks - need to address that in a future PR.
1 parent c8046ca commit bae2fe5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/ui/src/elements/CodeEditor/CodeEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ const Editor = (EditorImport.default || EditorImport) as unknown as typeof Edito
1313
const baseClass = 'code-editor'
1414

1515
const CodeEditor: React.FC<Props> = (props) => {
16-
const { className, maxHeight, options, readOnly, ...rest } = props
17-
const [dynamicHeight, setDynamicHeight] = useState(20)
18-
const { theme } = useTheme()
16+
const { className, maxHeight, minHeight, options, readOnly, ...rest } = props
17+
const MIN_HEIGHT = minHeight ?? 56 // equivalent to 3 lines
1918

20-
const MIN_HEIGHT = 56 // equivalent to 3 lines
19+
const [dynamicHeight, setDynamicHeight] = useState(MIN_HEIGHT)
20+
const { theme } = useTheme()
2121

2222
const classes = [
2323
baseClass,

packages/ui/src/elements/CodeEditor/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ import type { EditorProps } from '@monaco-editor/react'
22

33
export type Props = {
44
maxHeight?: number
5+
/**
6+
* @default 56 (3 lines)
7+
*/
8+
minHeight?: number
59
readOnly?: boolean
610
} & EditorProps

0 commit comments

Comments
 (0)