Skip to content

Commit 990e15c

Browse files
authored
fix: reflect maxRows in TextareaComposer and allow to add lines (#2709)
1 parent 54836b7 commit 990e15c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/components/TextareaComposer/TextareaComposer.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const TextareaComposer = ({
6464
closeSuggestionsOnClickOutside,
6565
containerClassName,
6666
listClassName,
67-
maxRows: maxRowsProp = 1,
67+
maxRows: maxRowsProp,
6868
minRows: minRowsProp,
6969
onBlur,
7070
onChange,
@@ -88,7 +88,7 @@ export const TextareaComposer = ({
8888
textareaRef,
8989
} = useMessageInputContext();
9090

91-
const maxRows = maxRowsProp ?? maxRowsContext;
91+
const maxRows = maxRowsProp ?? maxRowsContext ?? 1;
9292
const minRows = minRowsProp ?? minRowsContext;
9393
const placeholder = placeholderProp ?? additionalTextareaProps?.placeholder;
9494
const shouldSubmit = shouldSubmitProp ?? shouldSubmitContext ?? defaultShouldSubmit;
@@ -143,18 +143,14 @@ export const TextareaComposer = ({
143143
return;
144144
}
145145

146-
if (event.key === 'Enter') {
147-
// allow next line only on Shift + Enter. Enter is reserved for submission.
148-
event.preventDefault();
149-
}
150-
151146
if (
152147
textComposer.suggestions &&
153148
textComposer.suggestions.searchSource.items?.length
154149
) {
155150
if (event.key === 'Escape') return textComposer.closeSuggestions();
156151
const loadedItems = textComposer.suggestions.searchSource.items;
157152
if (event.key === 'Enter') {
153+
event.preventDefault();
158154
textComposer.handleSelect(loadedItems[focusedItemIndex]);
159155
}
160156
if (event.key === 'ArrowUp') {

0 commit comments

Comments
 (0)