File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
src/Shared/Components/Textarea Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { TextareaProps } from './types'
10
10
import { TEXTAREA_CONSTRAINTS } from './constants'
11
11
import './textarea.scss'
12
12
13
- const { MIN_HEIGHT , MAX_HEIGHT } = TEXTAREA_CONSTRAINTS
13
+ const { MIN_HEIGHT , AUTO_EXPANSION_MAX_HEIGHT } = TEXTAREA_CONSTRAINTS
14
14
15
15
const Textarea = ( {
16
16
name,
@@ -37,18 +37,19 @@ const Textarea = ({
37
37
}
38
38
39
39
const reInitHeight = ( ) => {
40
+ const currentHeight = parseInt ( textareaRef ?. current ?. style . height , 10 )
40
41
let nextHeight = textareaRef ?. current ?. scrollHeight || 0
41
42
42
- if ( nextHeight < parseInt ( textareaRef ?. current ?. style . height , 10 ) ) {
43
+ if ( nextHeight < currentHeight || currentHeight > AUTO_EXPANSION_MAX_HEIGHT ) {
43
44
return
44
45
}
45
46
46
47
if ( nextHeight < MIN_HEIGHT ) {
47
48
nextHeight = MIN_HEIGHT
48
49
}
49
50
50
- if ( nextHeight > MAX_HEIGHT ) {
51
- nextHeight = MAX_HEIGHT
51
+ if ( nextHeight > AUTO_EXPANSION_MAX_HEIGHT ) {
52
+ nextHeight = AUTO_EXPANSION_MAX_HEIGHT
52
53
}
53
54
54
55
updateRefsHeight ( nextHeight )
@@ -114,7 +115,8 @@ const Textarea = ({
114
115
className = { `${ COMPONENT_SIZE_TYPE_TO_FONT_AND_BLOCK_PADDING_MAP [ size ] } ${ COMPONENT_SIZE_TYPE_TO_INLINE_PADDING_MAP [ size ] } w-100 dc__overflow-auto textarea` }
115
116
ref = { textareaRef }
116
117
style = { {
117
- maxHeight : MAX_HEIGHT ,
118
+ // No max height when user is expanding
119
+ maxHeight : 'none' ,
118
120
minHeight : MIN_HEIGHT ,
119
121
} }
120
122
/>
Original file line number Diff line number Diff line change 1
1
export const TEXTAREA_CONSTRAINTS = {
2
2
MIN_HEIGHT : 56 ,
3
- MAX_HEIGHT : 140 ,
3
+ AUTO_EXPANSION_MAX_HEIGHT : 140 ,
4
4
}
You can’t perform that action at this time.
0 commit comments