File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/components/MessageInput/hooks Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -262,15 +262,22 @@ export default function useMessageInput(props) {
262262
263263 const insertText = useCallback (
264264 ( textToInsert ) => {
265+ const { maxLength } = additionalTextareaProps ;
266+
265267 if ( ! textareaRef . current ) {
266268 dispatch ( {
267269 type : 'setText' ,
268- getNewText : ( t ) => t + textToInsert ,
270+ getNewText : ( t ) => {
271+ const updatedText = t + textToInsert ;
272+ if ( updatedText . length > maxLength ) {
273+ return updatedText . slice ( 0 , maxLength ) ;
274+ }
275+ return updatedText ;
276+ } ,
269277 } ) ;
270278 return ;
271279 }
272280
273- const { maxLength } = additionalTextareaProps ;
274281 const { selectionStart, selectionEnd } = textareaRef . current ;
275282 newCursorPosition . current = selectionStart + textToInsert . length ;
276283
You can’t perform that action at this time.
0 commit comments