Skip to content

Commit

Permalink
Merge pull request #18968 from Scroody/fix-chat-input-focus
Browse files Browse the repository at this point in the history
Client: Focus on input when clicking chat
  • Loading branch information
ramonlsouza committed Oct 23, 2023
2 parents 81a8b15 + 5952fae commit fc18772
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ const ChatMessageForm: React.FC<ChatMessageFormProps> = ({
}
};

document.addEventListener('click', (event) => {
const chatList = document.getElementById('chat-list');
if (chatList?.contains(event.target as Node)) {
const selection = window.getSelection()?.toString();
if (selection?.length === 0) {
textAreaRef.current?.textarea.focus();
}
}
});

if (sendGroupChatMsgError) { return <div>something went wrong</div>; }

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const ChatMessageList: React.FC<ChatListProps> = ({
<>
{
[
<MessageListWrapper key="message-list-wrapper">
<MessageListWrapper key="message-list-wrapper" id="chat-list">
<MessageList
ref={messageListRef}
onWheel={(e) => {
Expand Down

0 comments on commit fc18772

Please sign in to comment.