Skip to content

Handle emoji tooltip #35838

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

Merged
merged 35 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b930ed4
implement tooltip for emoji
dukenv0307 Jan 18, 2024
7385bf2
Merge branch 'main' into fix/34307
dukenv0307 Jan 24, 2024
925d6c3
implement tooltip for emoji
dukenv0307 Jan 24, 2024
ff81b72
write new file in typescript
dukenv0307 Jan 24, 2024
b6ecd0f
merge main
dukenv0307 Feb 5, 2024
21d6337
Merge branch 'main' into fix/34307
dukenv0307 Feb 5, 2024
d5f99a0
Merge branch 'main' into fix/34307
dukenv0307 Feb 5, 2024
ab0f57b
fix edge case
dukenv0307 Feb 5, 2024
54a21ae
write new page on ts
dukenv0307 Feb 5, 2024
046522e
revert local change
dukenv0307 Feb 6, 2024
47e78b6
disable tooltip for native
dukenv0307 Feb 6, 2024
a0f72ef
Merge branch 'main' into fix/34307
dukenv0307 Feb 6, 2024
4a9f29e
bump version of expensify-common
dukenv0307 Feb 6, 2024
2b5ec33
Merge branch 'main' into fix/34307
dukenv0307 Feb 7, 2024
1de60ab
Update src/styles/index.ts
dukenv0307 Feb 10, 2024
5a6a291
Merge branch 'main' into fix/34307
dukenv0307 Feb 10, 2024
2755f34
merge main
dukenv0307 Feb 10, 2024
a9bd9b4
fix ts error
dukenv0307 Feb 10, 2024
a0e43e0
merge main
dukenv0307 Feb 13, 2024
05c9b28
Merge branch 'main' into fix/34307
dukenv0307 Feb 13, 2024
0501a41
merge main
dukenv0307 Feb 15, 2024
439e629
fix the case emoji that is made up by some different emojis
dukenv0307 Feb 19, 2024
cf36e9b
Merge branch 'main' into fix/34307
dukenv0307 Feb 22, 2024
d622078
update version expesify-common
dukenv0307 Feb 22, 2024
7a65924
Merge branch 'main' into fix/34307
dukenv0307 Feb 22, 2024
db43ff1
Merge branch 'main' into fix/34307
dukenv0307 Feb 26, 2024
7eedaf3
add new attribute for emoji tag if contain only emoji
dukenv0307 Feb 26, 2024
5382c13
Merge branch 'main' into fix/34307
dukenv0307 Feb 27, 2024
62d558d
add check shouldRenderAsText for seprate platform
dukenv0307 Feb 27, 2024
1a34f6b
merge main
dukenv0307 Feb 28, 2024
a37188a
fix case delete emoji
dukenv0307 Feb 28, 2024
4cad935
merge main
dukenv0307 Mar 1, 2024
2a292da
Merge branch 'main' into fix/34307
dukenv0307 Mar 4, 2024
5f599ae
fix test
dukenv0307 Mar 4, 2024
bcb3510
fix lint
dukenv0307 Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/pages/home/report/comment/TextCommentFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import CONST from '@src/CONST';
import type {OriginalMessageSource} from '@src/types/onyx/OriginalMessage';
import type {Message} from '@src/types/onyx/ReportAction';
import RenderCommentHTML from './RenderCommentHTML';
import shouldRenderAsText from './shouldRenderAsText';

type TextCommentFragmentProps = {
/** The reportAction's source */
Expand Down Expand Up @@ -44,13 +45,10 @@ function TextCommentFragment({fragment, styleAsDeleted, source, style, displayAs
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();

// If the only difference between fragment.text and fragment.html is <br /> tags
// we render it as text, not as html.
// This is done to render emojis with line breaks between them as text.
const differByLineBreaksOnly = Str.replaceAll(html, '<br />', '\n') === text;

// Only render HTML if we have html in the fragment
if (!differByLineBreaksOnly) {
// If the only difference between fragment.text and fragment.html is <br /> tags and emoji tag
// 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
if (!shouldRenderAsText(html, text)) {
const editedTag = fragment.isEdited ? `<edited ${styleAsDeleted ? 'deleted' : ''}></edited>` : '';
const htmlWithDeletedTag = styleAsDeleted ? `<del>${html}</del>` : html;

Expand Down
12 changes: 12 additions & 0 deletions src/pages/home/report/comment/shouldRenderAsText.native.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new directory shouldRenderAsText and add index.native.ts, index.ts and types.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Str from 'expensify-common/lib/str';

/**
* Whether to render the report action as text
*/
export default function shouldRenderAsText(html: string, text: string): boolean {
// On native, we render emoji as text to prevent the large emoji is cut off when the action is edited.
// More info: https://github.com/Expensify/App/pull/35838#issuecomment-1964839350
const htmlWithoutLineBreak = Str.replaceAll(html, '<br />', '\n');
const htmlWithoutEmojiOpenTag = Str.replaceAll(htmlWithoutLineBreak, '<emoji>', '');
return Str.replaceAll(htmlWithoutEmojiOpenTag, '</emoji>', '') === text;
}
8 changes: 8 additions & 0 deletions src/pages/home/report/comment/shouldRenderAsText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Str from 'expensify-common/lib/str';

/**
* Whether to render the report action as text
*/
export default function shouldRenderAsText(html: string, text: string): boolean {
return Str.replaceAll(html, '<br />', '\n') === text;
}