Skip to content

Commit 4c77d10

Browse files
committed
fix: keep send button disabled until message composer has content
1 parent e78d366 commit 4c77d10

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { SendIcon } from '../../assets';
22
import React from 'react';
3-
import type { SendButtonProps } from 'stream-chat-react';
3+
import {SendButtonProps, useMessageComposerHasSendableData} from 'stream-chat-react';
44

5-
const SendButton = ({sendMessage, ...rest}: SendButtonProps) => (
6-
<button
7-
className='str-chat__send-button'
8-
onClick={sendMessage}
9-
type='button'
10-
{...rest}
11-
>
12-
<SendIcon />
13-
</button>
14-
);
5+
const SendButton = ({sendMessage, ...rest}: SendButtonProps) => {
6+
const hasSendableData = useMessageComposerHasSendableData();
7+
return (
8+
<button
9+
className='str-chat__send-button'
10+
disabled={!hasSendableData}
11+
onClick={sendMessage}
12+
type='button'
13+
{...rest}
14+
>
15+
<SendIcon/>
16+
</button>
17+
);
18+
};
1519

1620
export default SendButton;

virtual-event/src/components/Chat/MessageInputUI.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const MessageInputUI = () => {
7575
const commandSearchSource = useMemo(() => new CommandSearchSource(textComposer.channel),
7676
[textComposer]
7777
);
78+
const hasSendableData = useMessageComposerHasSendableData();
7879

7980
return (
8081
<div className='input-ui-container'>
@@ -85,7 +86,7 @@ export const MessageInputUI = () => {
8586
<>
8687
<button
8788
className={`input-ui-input-commands-button ${cooldownRemaining ? 'cooldown' : ''}`}
88-
disabled={!!cooldownRemaining}
89+
disabled={!!cooldownRemaining || !hasSendableData}
8990
onClick={() => {
9091
commandSearchSource.resetStateAndActivate();
9192
commandSearchSource.search();

0 commit comments

Comments
 (0)