Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/components/TextareaComposer/TextareaComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
closeSuggestionsOnClickOutside,
containerClassName,
listClassName,
maxRows: maxRowsProp = 1,
maxRows: maxRowsProp,
minRows: minRowsProp,
onBlur,
onChange,
Expand All @@ -88,7 +88,7 @@
textareaRef,
} = useMessageInputContext();

const maxRows = maxRowsProp ?? maxRowsContext;
const maxRows = maxRowsProp ?? maxRowsContext ?? 1;
const minRows = minRowsProp ?? minRowsContext;
const placeholder = placeholderProp ?? additionalTextareaProps?.placeholder;
const shouldSubmit = shouldSubmitProp ?? shouldSubmitContext ?? defaultShouldSubmit;
Expand Down Expand Up @@ -143,18 +143,14 @@
return;
}

if (event.key === 'Enter') {
// allow next line only on Shift + Enter. Enter is reserved for submission.
event.preventDefault();
}

if (
textComposer.suggestions &&
textComposer.suggestions.searchSource.items?.length
) {
if (event.key === 'Escape') return textComposer.closeSuggestions();
const loadedItems = textComposer.suggestions.searchSource.items;
if (event.key === 'Enter') {
event.preventDefault();

Check warning on line 153 in src/components/TextareaComposer/TextareaComposer.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/TextareaComposer/TextareaComposer.tsx#L153

Added line #L153 was not covered by tests
textComposer.handleSelect(loadedItems[focusedItemIndex]);
}
if (event.key === 'ArrowUp') {
Expand Down