File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/Shared/Components/Textarea Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
- import { useEffect , useRef } from 'react'
1
+ import { TextareaHTMLAttributes , useRef } from 'react'
2
2
import {
3
3
COMPONENT_SIZE_TYPE_TO_FONT_AND_BLOCK_PADDING_MAP ,
4
4
COMPONENT_SIZE_TYPE_TO_INLINE_PADDING_MAP ,
@@ -54,10 +54,6 @@ const Textarea = ({
54
54
updateRefsHeight ( nextHeight )
55
55
}
56
56
57
- useEffect ( ( ) => {
58
- reInitHeight ( )
59
- } , [ ] )
60
-
61
57
useThrottledEffect ( reInitHeight , 300 , [ props . value ] )
62
58
63
59
const handleBlur : TextareaProps [ 'onBlur' ] = ( event ) => {
@@ -77,6 +73,14 @@ const Textarea = ({
77
73
}
78
74
}
79
75
76
+ const handleKeyDown : TextareaHTMLAttributes < HTMLTextAreaElement > [ 'onKeyDown' ] = (
77
+ event : React . KeyboardEvent < HTMLTextAreaElement > ,
78
+ ) => {
79
+ if ( event . key === 'Enter' || event . key === 'Escape' ) {
80
+ event . stopPropagation ( )
81
+ }
82
+ }
83
+
80
84
return (
81
85
< FormFieldWrapper
82
86
inputId = { name }
@@ -106,6 +110,7 @@ const Textarea = ({
106
110
data-testid = { name }
107
111
required = { required }
108
112
onBlur = { handleBlur }
113
+ onKeyDown = { handleKeyDown }
109
114
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` }
110
115
ref = { textareaRef }
111
116
style = { {
You can’t perform that action at this time.
0 commit comments