@@ -4,13 +4,13 @@ import type { DefaultOptionsRule } from '@js/core/options/utils';
44import type { dxElementWrapper } from '@js/core/renderer' ;
55import $ from '@js/core/renderer' ;
66import { getOuterHeight } from '@js/core/utils/size' ;
7+ import type { NativeEventInfo } from '@js/events' ;
78import type {
89 ClickEvent ,
910 InitializedEvent ,
1011} from '@js/ui/button' ;
1112import type Button from '@js/ui/button' ;
1213import type { Properties as FileUploaderProperties } from '@js/ui/file_uploader' ;
13- import type { EnterKeyEvent } from '@js/ui/text_area' ;
1414import { current , isMaterial } from '@js/ui/themes' ;
1515import type { Item as ToolbarItem } from '@js/ui/toolbar' ;
1616import Toolbar from '@js/ui/toolbar' ;
@@ -24,10 +24,14 @@ const TEXT_AREA_WITH_TOOLBAR = 'dx-textarea-with-toolbar';
2424
2525const isMobile = ( ) : boolean => devices . current ( ) . deviceType !== 'desktop' ;
2626
27+ type EnterKeyEvent = NativeEventInfo < ChatTextArea , KeyboardEvent > ;
28+
29+ export type SendEvent = ClickEvent | EnterKeyEvent ;
30+
2731export type Properties = TextAreaProperties & {
2832 fileUploaderOptions ?: FileUploaderProperties ;
2933
30- onSend ?: ( e : ClickEvent | EnterKeyEvent ) => void ;
34+ onSend ?: ( e : SendEvent ) => void ;
3135} ;
3236
3337class ChatTextArea extends TextArea < Properties > {
@@ -37,8 +41,7 @@ class ChatTextArea extends TextArea<Properties> {
3741
3842 _sendButton ?: Button ;
3943
40- /** KeyboardEvent should be replaced with EnterKeyEvent */
41- _sendAction ?: ( e : Partial < ClickEvent | KeyboardEvent > ) => void ;
44+ _sendAction ?: ( e : SendEvent ) => void ;
4245
4346 _getDefaultOptions ( ) : Properties {
4447 return {
@@ -72,7 +75,11 @@ class ChatTextArea extends TextArea<Properties> {
7275 enter : ( e ) : void => {
7376 if ( ! e ?. shiftKey && this . _isValuableTextEntered ( ) && ! isMobile ( ) ) {
7477 e . preventDefault ( ) ;
75- this . _processSendPress ( e ) ;
78+ this . _processSendButtonActivation ( {
79+ component : this ,
80+ element : this . element ( ) ,
81+ event : e ,
82+ } ) ;
7683 }
7784 } ,
7885 } ;
@@ -172,7 +179,7 @@ class ChatTextArea extends TextArea<Properties> {
172179 'aria-label' : messageLocalization . format ( 'dxChat-sendButtonAriaLabel' ) ,
173180 } ,
174181 onClick : ( e : ClickEvent ) : void => {
175- this . _processSendPress ( e ) ;
182+ this . _processSendButtonActivation ( e ) ;
176183 } ,
177184 onInitialized : ( e : InitializedEvent ) : void => {
178185 this . _sendButton = e . component ;
@@ -204,7 +211,7 @@ class ChatTextArea extends TextArea<Properties> {
204211 this . _toggleButtonDisableState ( shouldButtonBeDisabled ) ;
205212 }
206213
207- _processSendPress ( e : ClickEvent | KeyboardEvent ) : void {
214+ _processSendButtonActivation ( e : SendEvent ) : void {
208215 this . _sendAction ?.( e ) ;
209216 this . reset ( ) ;
210217 this . _toggleButtonDisableState ( true ) ;
0 commit comments