We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent afc7e72 commit 5a4cbe2Copy full SHA for 5a4cbe2
1 file changed
src/components/MessageInput/hooks/messageInput.js
@@ -262,15 +262,22 @@ export default function useMessageInput(props) {
262
263
const insertText = useCallback(
264
(textToInsert) => {
265
+ const { maxLength } = additionalTextareaProps;
266
+
267
if (!textareaRef.current) {
268
dispatch({
269
type: 'setText',
- 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
+ },
277
});
278
return;
279
}
280
- const { maxLength } = additionalTextareaProps;
281
const { selectionStart, selectionEnd } = textareaRef.current;
282
newCursorPosition.current = selectionStart + textToInsert.length;
283
0 commit comments