-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Global create emoji is overlapping the message with markdown #77790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d1a45bf
18c2547
5a319ab
3059588
3861597
7b54594
9cd91b2
836c12b
6132fa8
31721e6
6118fa8
e78ef63
f691cd2
1199e40
f2d09e5
94849b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,24 +1,24 @@ | ||||||||||||||||||||||||||||||
| import React, {useMemo} from 'react'; | ||||||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||||||
| import type {TextStyle} from 'react-native'; | ||||||||||||||||||||||||||||||
| import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html'; | ||||||||||||||||||||||||||||||
| import EmojiWithTooltip from '@components/EmojiWithTooltip'; | ||||||||||||||||||||||||||||||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function EmojiRenderer({tnode, style: styleProp}: CustomRendererProps<TText | TPhrasing>) { | ||||||||||||||||||||||||||||||
| const styles = useThemeStyles(); | ||||||||||||||||||||||||||||||
| const style = useMemo(() => { | ||||||||||||||||||||||||||||||
| if ('islarge' in tnode.attributes) { | ||||||||||||||||||||||||||||||
| return [styleProp as TextStyle, styles.onlyEmojisText]; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if ('ismedium' in tnode.attributes) { | ||||||||||||||||||||||||||||||
| return [styleProp as TextStyle, styles.emojisWithTextFontSize, styles.verticalAlignTopText]; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| let style; | ||||||||||||||||||||||||||||||
| if ('islarge' in tnode.attributes) { | ||||||||||||||||||||||||||||||
| style = [styleProp as TextStyle, styles.onlyEmojisText]; | ||||||||||||||||||||||||||||||
| } else if ('ismedium' in tnode.attributes) { | ||||||||||||||||||||||||||||||
| style = [styleProp as TextStyle, styles.emojisWithTextFontSize, styles.verticalAlignTopText]; | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| style = null; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @truph01 Updated |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||
| }, [tnode.attributes, styles, styleProp]); | ||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <EmojiWithTooltip | ||||||||||||||||||||||||||||||
| isOnSeparateLine={'oneline' in tnode.attributes} | ||||||||||||||||||||||||||||||
| style={[style, styles.cursorDefault, styles.emojiDefaultStyles]} | ||||||||||||||||||||||||||||||
| emojiCode={'data' in tnode ? tnode.data : ''} | ||||||||||||||||||||||||||||||
| isMedium={'ismedium' in tnode.attributes} | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import {Str} from 'expensify-common'; | ||
| import isEmpty from 'lodash/isEmpty'; | ||
| import React, {memo, useEffect, useMemo} from 'react'; | ||
| import React, {useEffect} from 'react'; | ||
| import type {StyleProp, TextStyle} from 'react-native'; | ||
| import Text from '@components/Text'; | ||
| import ZeroWidthView from '@components/ZeroWidthView'; | ||
|
|
@@ -11,7 +11,7 @@ import useTheme from '@hooks/useTheme'; | |
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import convertToLTR from '@libs/convertToLTR'; | ||
| import {canUseTouchScreen} from '@libs/DeviceCapabilities'; | ||
| import {containsOnlyCustomEmoji as containsOnlyCustomEmojiUtil, containsOnlyEmojis as containsOnlyEmojisUtil, splitTextWithEmojis} from '@libs/EmojiUtils'; | ||
| import {containsOnlyCustomEmoji as containsOnlyCustomEmojiUtil, containsOnlyEmojis as containsOnlyEmojisUtil, isEmojiOnSeparateLine, splitTextWithEmojis} from '@libs/EmojiUtils'; | ||
| import Parser from '@libs/Parser'; | ||
| import Performance from '@libs/Performance'; | ||
| import {getHtmlWithAttachmentID, getTextFromHtml} from '@libs/ReportActionsUtils'; | ||
|
|
@@ -62,7 +62,7 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM | |
|
|
||
| const message = isEmpty(iouMessage) ? text : iouMessage; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-4 (docs)Removing Fix: Restore the const processedTextArray = useMemo(() => splitTextWithEmojis(message), [message]); |
||
| const processedTextArray = useMemo(() => splitTextWithEmojis(message), [message]); | ||
| const processedTextArray = splitTextWithEmojis(message); | ||
|
|
||
| useEffect(() => { | ||
| Performance.markEnd(CONST.TIMING.SEND_MESSAGE, {message: text}); | ||
|
|
@@ -74,7 +74,7 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM | |
| // on native, we render it as text, not as html | ||
| // on other device, only render it as text if the only difference is <br /> tag | ||
| const containsOnlyEmojis = containsOnlyEmojisUtil(text ?? ''); | ||
| const containsOnlyCustomEmoji = useMemo(() => containsOnlyCustomEmojiUtil(text), [text]); | ||
| const containsOnlyCustomEmoji = containsOnlyCustomEmojiUtil(text); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-4 (docs)Removing Fix: Restore the const containsOnlyCustomEmoji = useMemo(() => containsOnlyCustomEmojiUtil(text), [text]); |
||
| const containsEmojis = CONST.REGEX.ALL_EMOJIS.test(text ?? ''); | ||
| if (!shouldRenderAsText(html, text ?? '') && !(containsOnlyEmojis && styleAsDeleted)) { | ||
| const editedTag = fragment?.isEdited ? `<edited ${styleAsDeleted ? 'deleted' : ''}></edited>` : ''; | ||
|
|
@@ -90,7 +90,15 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM | |
| if (!htmlContent.includes('<emoji>')) { | ||
| htmlContent = Parser.replace(htmlContent, {filterRules: ['emoji'], shouldEscapeText: false}); | ||
| } | ||
| htmlContent = Str.replaceAll(htmlContent, '<emoji>', '<emoji ismedium>'); | ||
| const lines = htmlContent.split(/<br\s*\/?>/i); | ||
| const processedLines = lines.map((line) => { | ||
| if (isEmojiOnSeparateLine(line)) { | ||
| return line.replace('<emoji>', '<emoji ismedium oneline >'); | ||
| } | ||
| return line.replace('<emoji>', '<emoji ismedium>'); | ||
| }); | ||
|
|
||
| htmlContent = processedLines.join('<br />'); | ||
| } | ||
|
|
||
| let htmlWithTag = editedTag ? `${htmlContent}${editedTag}` : htmlContent; | ||
|
|
@@ -158,4 +166,4 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM | |
| ); | ||
| } | ||
|
|
||
| export default memo(TextCommentFragment); | ||
| export default TextCommentFragment; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-4 (docs)Removing Fix: Restore the export default memo(TextCommentFragment);
paulnjs marked this conversation as resolved.
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulnjs You shouldn't remove
import Reacthere. It will cause a crash appThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@truph01 Updated