@@ -21,14 +21,22 @@ export interface ChatFieldProps extends TextAreaProps, TestableComponent {
2121 * Component to input chat text.
2222 * Based on `TextArea` component.
2323 */
24- export const ChatField = ( { className, onTextSubmit, rightElement, ...otherTextAreaProps } : ChatFieldProps ) => {
24+ export const ChatField = ( {
25+ className,
26+ onTextSubmit,
27+ onChange,
28+ onKeyDown,
29+ rightElement,
30+ ...otherTextAreaProps
31+ } : ChatFieldProps ) => {
2532 const chatvalue = React . useRef < string > ( otherTextAreaProps . children ?? "" ) ;
2633
2734 const onContentChange = ( value : string ) => {
2835 chatvalue . current = value ;
2936 } ;
3037
3138 const onEnter = ( e : React . KeyboardEvent < HTMLTextAreaElement > ) => {
39+ if ( onKeyDown ) onKeyDown ( e ) ;
3240 if ( e . keyCode === 13 && e . shiftKey === false && onTextSubmit ) {
3341 e . preventDefault ( ) ;
3442 onTextSubmit ( chatvalue . current ) ;
@@ -40,10 +48,15 @@ export const ChatField = ({ className, onTextSubmit, rightElement, ...otherTextA
4048 fill
4149 autoResize
4250 className = { `${ eccgui } -chat__inputfield` + ( className ? ` ${ className } ` : "" ) }
43- onChange = { ( e : React . ChangeEvent < HTMLTextAreaElement > ) => {
44- onContentChange ( e . target . value ) ;
45- } }
46- onKeyDown = { onTextSubmit ? onEnter : undefined }
51+ onChange = {
52+ onTextSubmit
53+ ? ( e : React . ChangeEvent < HTMLTextAreaElement > ) => {
54+ onContentChange ( e . target . value ) ;
55+ if ( onChange ) onChange ( e ) ;
56+ }
57+ : onChange
58+ }
59+ onKeyDown = { onTextSubmit ? onEnter : onKeyDown }
4760 rightElement = {
4861 ( onTextSubmit || rightElement ) && (
4962 < >
0 commit comments