Merge pull request #2431 from Bilb/fix-double-clcik-emoji-picker-reply-msg

fix: make sure a double click on the picker does not trigger reply msg
pull/2432/head
Audric Ackermann 3 years ago committed by GitHub
commit 506eb20faf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,6 +30,7 @@ type Props = {
dataTestId?: string; dataTestId?: string;
enableReactions: boolean; enableReactions: boolean;
}; };
// tslint:disable: use-simple-attributes
const StyledMessageContentContainer = styled.div<{ direction: 'left' | 'right' }>` const StyledMessageContentContainer = styled.div<{ direction: 'left' | 'right' }>`
display: flex; display: flex;
@ -66,17 +67,19 @@ export const MessageContentWithStatuses = (props: Props) => {
const currentSelection = window.getSelection(); const currentSelection = window.getSelection();
const currentSelectionString = currentSelection?.toString() || undefined; const currentSelectionString = currentSelection?.toString() || undefined;
// if multiple word are selected, consider that this double click was actually NOT used to reply to if ((e.target as any).localName !== 'em-emoji-picker') {
// but to select if (
if ( !currentSelectionString ||
!currentSelectionString || currentSelectionString.length === 0 ||
currentSelectionString.length === 0 || !/\s/.test(currentSelectionString)
!currentSelectionString.includes(' ') ) {
) { // if multiple word are selected, consider that this double click was actually NOT used to reply to
void replyToMessage(messageId); // but to select
currentSelection?.empty(); void replyToMessage(messageId);
e.preventDefault(); currentSelection?.empty();
return; e.preventDefault();
return;
}
} }
}; };

Loading…
Cancel
Save