Skip to content

Commit c2b2ddf

Browse files
committed
fix: reflect MessageInputContext values in TextareaComposer
1 parent 8f93b99 commit c2b2ddf

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

src/components/MessageInput/EditMessageForm.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export const EditMessageModal = ({
8686
>
8787
<MessageInput
8888
clearEditingState={clearEditingState}
89-
grow
9089
hideSendButton
9190
Input={EditMessageInput}
9291
{...additionalMessageInputProps}

src/components/MessageInput/MessageInput.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type MessageInputProps = {
3838
*/
3939
additionalTextareaProps?: Omit<
4040
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
41-
'defaultValue'
41+
'defaultValue' | 'style' | 'disabled'
4242
>;
4343
/**
4444
* When enabled, recorded messages won’t be sent immediately.
@@ -55,8 +55,6 @@ export type MessageInputProps = {
5555
emojiSearchIndex?: ComponentContextValue['emojiSearchIndex'];
5656
/** If true, focuses the text input on component mount */
5757
focus?: boolean;
58-
/** If true, expands the text input vertically for new lines */
59-
grow?: boolean;
6058
/** Allows to hide MessageInput's send button. */
6159
hideSendButton?: boolean;
6260
/** Custom UI component handling how the message input is rendered, defaults to and accepts the same props as [MessageInputFlat](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/MessageInputFlat.tsx) */

src/components/MessageInput/hooks/useCreateMessageInputContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const useCreateMessageInputContext = (value: MessageInputContextValue) =>
1212
cooldownRemaining,
1313
emojiSearchIndex,
1414
focus,
15-
grow,
1615
handleSubmit,
1716
hideSendButton,
1817
insertText,
@@ -39,7 +38,6 @@ export const useCreateMessageInputContext = (value: MessageInputContextValue) =>
3938
cooldownRemaining,
4039
emojiSearchIndex,
4140
focus,
42-
grow,
4341
handleSubmit,
4442
hideSendButton,
4543
insertText,

src/components/TextareaComposer/TextareaComposer.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,46 +46,42 @@ export type TextComposerProps = Omit<
4646
> & {
4747
closeSuggestionsOnClickOutside?: boolean;
4848
containerClassName?: string;
49-
dropdownClassName?: string;
50-
grow?: boolean;
51-
itemClassName?: string;
5249
listClassName?: string;
5350
maxRows?: number;
51+
minRows?: number;
5452
shouldSubmit?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => boolean;
5553
};
5654

5755
export const TextareaComposer = ({
5856
className,
5957
closeSuggestionsOnClickOutside,
6058
containerClassName,
61-
// dropdownClassName, // todo: X find a different way to prevent prop drilling
62-
grow: growProp,
63-
// itemClassName, // todo: X find a different way to prevent prop drilling
6459
listClassName,
6560
maxRows: maxRowsProp = 1,
61+
minRows: minRowsProp,
6662
onBlur,
6763
onChange,
6864
onKeyDown,
6965
onScroll,
7066
placeholder: placeholderProp,
7167
shouldSubmit: shouldSubmitProp,
72-
...restProps
68+
...restTextareaProps
7369
}: TextComposerProps) => {
7470
const { t } = useTranslationContext();
7571
const { AutocompleteSuggestionList = DefaultSuggestionList } = useComponentContext();
7672
const {
7773
additionalTextareaProps,
7874
cooldownRemaining,
79-
grow: growContext,
8075
handleSubmit,
8176
maxRows: maxRowsContext,
77+
minRows: minRowsContext,
8278
onPaste,
8379
shouldSubmit: shouldSubmitContext,
8480
textareaRef,
8581
} = useMessageInputContext();
8682

87-
const grow = growProp ?? growContext;
8883
const maxRows = maxRowsProp ?? maxRowsContext;
84+
const minRows = minRowsProp ?? minRowsContext;
8985
const placeholder = placeholderProp ?? additionalTextareaProps?.placeholder;
9086
const shouldSubmit = shouldSubmitProp ?? shouldSubmitContext ?? defaultShouldSubmit;
9187

@@ -235,7 +231,7 @@ export const TextareaComposer = ({
235231
ref={containerRef}
236232
>
237233
<Textarea
238-
{...restProps}
234+
{...{ ...additionalTextareaProps, ...restTextareaProps }}
239235
aria-label={cooldownRemaining ? t('Slow Mode ON') : placeholder}
240236
className={clsx(
241237
'rta__textarea',
@@ -244,7 +240,8 @@ export const TextareaComposer = ({
244240
)}
245241
data-testid='message-input'
246242
disabled={!enabled || !!cooldownRemaining}
247-
maxRows={grow ? maxRows : 1}
243+
maxRows={maxRows}
244+
minRows={minRows}
248245
onBlur={onBlur}
249246
onChange={changeHandler}
250247
onCompositionEnd={onCompositionEnd}

0 commit comments

Comments
 (0)