Merge pull request #20816 from Scroody/fix-double-click-chat-select

Fix: Unable to focus chat when double clicking it
This commit is contained in:
Ramón Souza 2024-08-01 15:25:00 -03:00 committed by GitHub
commit 835e53da77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View File

@ -33,6 +33,7 @@ export const ChatMessages = styled.div<ChatMessagesProps>`
`}
padding-bottom: ${smPaddingX};
user-select: text;
`;
export const MessageList = styled(ScrollboxVertical)`
@ -42,6 +43,7 @@ export const MessageList = styled(ScrollboxVertical)`
padding-top: 0;
outline-style: none;
overflow-x: hidden;
user-select: none;
[dir='rtl'] & {
margin: 0 0 0 auto;

View File

@ -21,6 +21,24 @@ interface ChatProps {
const Chat: React.FC<ChatProps> = ({ isRTL }) => {
const { isChrome } = browserInfo;
React.useEffect(() => {
const handleMouseDown = () => {
if (window.getSelection) {
const selection = window.getSelection();
if (selection) {
selection.removeAllRanges();
}
}
};
document.addEventListener('mousedown', handleMouseDown);
return () => {
document.removeEventListener('mousedown', handleMouseDown);
};
}, []);
return (
<Styled.Chat isRTL={isRTL} isChrome={isChrome}>
<ChatHeader />
@ -30,7 +48,6 @@ const Chat: React.FC<ChatProps> = ({ isRTL }) => {
</Styled.Chat>
);
};
export const ChatLoading: React.FC<ChatProps> = ({ isRTL }) => {
const { isChrome } = browserInfo;
return (

View File

@ -18,6 +18,7 @@ export const Chat = styled.div<ChatProps>`
justify-content: space-around;
overflow: hidden;
height: 100%;
user-select: none;
${({ isRTL }) => isRTL && `
padding-left: 0.1rem;
@ -70,6 +71,8 @@ const ChatContent = styled.div`
display: contents;
`;
const ChatMessages = styled.div``;
const ChatMessages = styled.div`
user-select: text;
`;
export default { Chat, ChatMessages, ChatContent };