Skip to content

Commit

Permalink
Fix: Display emoji in visual format and enable send icon on emoji sel…
Browse files Browse the repository at this point in the history
…ection
  • Loading branch information
SinghaAnirban005 committed Nov 9, 2024
1 parent 467c5b4 commit 5433169
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/react/src/views/ChatInput/ChatInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import useAttachmentWindowStore from '../../store/attachmentwindow';
import MembersList from '../Mentions/MembersList';
import { TypingUsers } from '../TypingUsers';
import createPendingMessage from '../../lib/createPendingMessage';
import { parseEmoji } from '../../lib/emoji';
import { CommandsList } from '../CommandList';
import useSettingsStore from '../../store/settingsStore';
import ChannelState from '../ChannelState/ChannelState';
Expand Down Expand Up @@ -150,6 +149,10 @@ const ChatInput = ({ scrollToBottom }) => {
});
}, [RCInstance, isChannelPrivate, setMembersHandler]);

const trigger = (val) => {
setDisableButton(!val.trim().length);
};

useEffect(() => {
if (editMessage.attachments) {
messageRef.current.value =
Expand Down Expand Up @@ -365,7 +368,7 @@ const ChatInput = ({ scrollToBottom }) => {
const onTextChange = (e) => {
sendTypingStart();
const message = e.target.value;
messageRef.current.value = parseEmoji(message);
messageRef.current.value = message;
setDisableButton(!messageRef.current.value.length);
handleNewLine(e, false);
searchMentionUser(message);
Expand Down Expand Up @@ -528,6 +531,7 @@ const ChatInput = ({ scrollToBottom }) => {
<ChatInputFormattingToolbar
messageRef={messageRef}
inputRef={inputRef}
triggerButton={trigger}
/>
)}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import AudioMessageRecorder from './AudioMessageRecorder';
import VideoMessageRecorder from './VideoMessageRecoder';
import { getChatInputFormattingToolbarStyles } from './ChatInput.styles';
import formatSelection from '../../lib/formatSelection';
import { parseEmoji } from '../../lib/emoji';

const ChatInputFormattingToolbar = ({
messageRef,
inputRef,
triggerButton,
optionConfig = {
surfaceItems: ['emoji', 'formatter', 'audio', 'video', 'file'],
formatters: ['bold', 'italic', 'strike', 'code', 'multiline'],
Expand Down Expand Up @@ -46,7 +48,12 @@ const ChatInputFormattingToolbar = ({

const handleEmojiClick = (emojiEvent) => {
const [emoji] = emojiEvent.names;
messageRef.current.value += ` :${emoji.replace(/[\s-]+/g, '_')}: `;
const message = `${messageRef.current.value} :${emoji.replace(
/[\s-]+/g,
'_'
)}: `;
messageRef.current.value = parseEmoji(message);
triggerButton?.(message);
};

const chatToolMap = {
Expand Down

0 comments on commit 5433169

Please sign in to comment.