From c2b2ddf4d6f93529660cc720974cba7f5ee2a0ff Mon Sep 17 00:00:00 2001 From: martincupela Date: Thu, 1 May 2025 14:43:13 +0200 Subject: [PATCH 1/7] fix: reflect MessageInputContext values in TextareaComposer --- .../MessageInput/EditMessageForm.tsx | 1 - src/components/MessageInput/MessageInput.tsx | 4 +--- .../hooks/useCreateMessageInputContext.ts | 2 -- .../TextareaComposer/TextareaComposer.tsx | 19 ++++++++----------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/components/MessageInput/EditMessageForm.tsx b/src/components/MessageInput/EditMessageForm.tsx index 072bf224a9..6e5bda7f2b 100644 --- a/src/components/MessageInput/EditMessageForm.tsx +++ b/src/components/MessageInput/EditMessageForm.tsx @@ -86,7 +86,6 @@ export const EditMessageModal = ({ > , - 'defaultValue' + 'defaultValue' | 'style' | 'disabled' >; /** * When enabled, recorded messages won’t be sent immediately. @@ -55,8 +55,6 @@ export type MessageInputProps = { emojiSearchIndex?: ComponentContextValue['emojiSearchIndex']; /** If true, focuses the text input on component mount */ focus?: boolean; - /** If true, expands the text input vertically for new lines */ - grow?: boolean; /** Allows to hide MessageInput's send button. */ hideSendButton?: boolean; /** 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) */ diff --git a/src/components/MessageInput/hooks/useCreateMessageInputContext.ts b/src/components/MessageInput/hooks/useCreateMessageInputContext.ts index c31522353c..4cb33c985e 100644 --- a/src/components/MessageInput/hooks/useCreateMessageInputContext.ts +++ b/src/components/MessageInput/hooks/useCreateMessageInputContext.ts @@ -12,7 +12,6 @@ export const useCreateMessageInputContext = (value: MessageInputContextValue) => cooldownRemaining, emojiSearchIndex, focus, - grow, handleSubmit, hideSendButton, insertText, @@ -39,7 +38,6 @@ export const useCreateMessageInputContext = (value: MessageInputContextValue) => cooldownRemaining, emojiSearchIndex, focus, - grow, handleSubmit, hideSendButton, insertText, diff --git a/src/components/TextareaComposer/TextareaComposer.tsx b/src/components/TextareaComposer/TextareaComposer.tsx index 8543e10a2e..2c36637e52 100644 --- a/src/components/TextareaComposer/TextareaComposer.tsx +++ b/src/components/TextareaComposer/TextareaComposer.tsx @@ -46,11 +46,9 @@ export type TextComposerProps = Omit< > & { closeSuggestionsOnClickOutside?: boolean; containerClassName?: string; - dropdownClassName?: string; - grow?: boolean; - itemClassName?: string; listClassName?: string; maxRows?: number; + minRows?: number; shouldSubmit?: (event: React.KeyboardEvent) => boolean; }; @@ -58,34 +56,32 @@ export const TextareaComposer = ({ className, closeSuggestionsOnClickOutside, containerClassName, - // dropdownClassName, // todo: X find a different way to prevent prop drilling - grow: growProp, - // itemClassName, // todo: X find a different way to prevent prop drilling listClassName, maxRows: maxRowsProp = 1, + minRows: minRowsProp, onBlur, onChange, onKeyDown, onScroll, placeholder: placeholderProp, shouldSubmit: shouldSubmitProp, - ...restProps + ...restTextareaProps }: TextComposerProps) => { const { t } = useTranslationContext(); const { AutocompleteSuggestionList = DefaultSuggestionList } = useComponentContext(); const { additionalTextareaProps, cooldownRemaining, - grow: growContext, handleSubmit, maxRows: maxRowsContext, + minRows: minRowsContext, onPaste, shouldSubmit: shouldSubmitContext, textareaRef, } = useMessageInputContext(); - const grow = growProp ?? growContext; const maxRows = maxRowsProp ?? maxRowsContext; + const minRows = minRowsProp ?? minRowsContext; const placeholder = placeholderProp ?? additionalTextareaProps?.placeholder; const shouldSubmit = shouldSubmitProp ?? shouldSubmitContext ?? defaultShouldSubmit; @@ -235,7 +231,7 @@ export const TextareaComposer = ({ ref={containerRef} >