Skip to content
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

Add clickable custom emoji support for onboarding task #55222

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
14 changes: 14 additions & 0 deletions assets/images/customEmoji/global-create.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const onboardingEmployerOrSubmitMessage: OnboardingMessage = {
'\n' +
'Here’s how to submit an expense:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button.\n' +
Copy link
Contributor

Choose a reason for hiding this comment

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

If pressablewithdefaultaction is removed, it should render a non-interactive emoji. It is crashing for me for this case on web.

Screen.Recording.2025-01-29.at.5.29.49.PM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this, I think I know why it happened

Additionally sorry, I did not make full testing, I pushed to pull and check the IOS on the laptop

'2. Choose *Create expense*.\n' +
'3. Enter an amount or scan a receipt.\n' +
'4. Add your reimburser to the request.\n' +
Expand All @@ -144,7 +144,7 @@ const combinedTrackSubmitOnboardingEmployerOrSubmitMessage: OnboardingMessage =
'\n' +
'Here’s how to submit an expense:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button\n' +
'2. Choose *Create expense*.\n' +
'3. Enter an amount or scan a receipt.\n' +
'4. Add your reimburser to the request.\n' +
Expand Down Expand Up @@ -175,7 +175,7 @@ const onboardingPersonalSpendMessage: OnboardingMessage = {
'\n' +
'Here’s how to track an expense:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button.\n' +
'2. Choose *Create expense*.\n' +
'3. Enter an amount or scan a receipt.\n' +
'4. Click "Just track it (don\'t submit it)".\n' +
Expand All @@ -198,7 +198,7 @@ const combinedTrackSubmitOnboardingPersonalSpendMessage: OnboardingMessage = {
'\n' +
'Here’s how to track an expense:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button.\n' +
'2. Choose *Create expense*.\n' +
'3. Enter an amount or scan a receipt.\n' +
'4. Click "Just track it (don\'t submit it)".\n' +
Expand Down Expand Up @@ -5172,7 +5172,7 @@ const CONST = {
'\n' +
'Here’s how to start a chat:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button.\n' +
'2. Choose *Start chat*.\n' +
'3. Enter emails or phone numbers.\n' +
'\n' +
Expand All @@ -5189,7 +5189,7 @@ const CONST = {
'\n' +
'Here’s how to request money:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button\n' +
'2. Choose *Start chat*.\n' +
'3. Enter any email, SMS, or name of who you want to split with.\n' +
'4. From within the chat, click the *+* button on the message bar, and click *Split expense*.\n' +
Expand Down Expand Up @@ -5239,7 +5239,7 @@ const CONST = {
'\n' +
'Here’s how to submit an expense:\n' +
'\n' +
'1. Click the green *+* button.\n' +
'1. Press the <custom-emoji emoji="action-menu-icon" pressablewithdefaultaction /> button.\n' +
'2. Choose *Create expense*.\n' +
'3. Enter an amount or scan a receipt.\n' +
'4. Add your reimburser to the request.\n' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function BaseHTMLEngineProvider({textSelectable = false, children, enableExperim
'mention-user': HTMLElementModel.fromCustomModel({tagName: 'mention-user', contentModel: HTMLContentModel.textual}),
'mention-report': HTMLElementModel.fromCustomModel({tagName: 'mention-report', contentModel: HTMLContentModel.textual}),
'mention-here': HTMLElementModel.fromCustomModel({tagName: 'mention-here', contentModel: HTMLContentModel.textual}),
'custom-emoji': HTMLElementModel.fromCustomModel({tagName: 'custom-emoji', contentModel: HTMLContentModel.textual}),
'next-step': HTMLElementModel.fromCustomModel({
tagName: 'next-step',
mixedUAStyles: {...styles.textLabelSupporting, ...styles.lh16},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import {Platform, View} from 'react-native';
import ImageSVG from '@components/ImageSVG';
import useThemeStyles from '@hooks/useThemeStyles';
import FloatingActionButtonAndPopover from '@pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover';
import variables from '@styles/variables';
import {emojiMap} from './HTMLRenderers/CustomEmojiRenderer';

type CustomEmojiWithDefaultPressableActionProps = {
emojiKey: string;
};

function CustomEmojiWithDefaultPressableAction({emojiKey}: CustomEmojiWithDefaultPressableActionProps) {
const styles = useThemeStyles();
const positionFix = Platform.OS !== 'web' && {height: '5%'};

const image = (
<View style={[styles.customEmoji, positionFix]}>
<ImageSVG
src={emojiMap[emojiKey]}
width={variables.iconSizeNormal}
height={variables.iconSizeNormal}
/>
</View>
);

if (emojiKey === 'action-menu-icon') {
return <FloatingActionButtonAndPopover isEmoji>{image}</FloatingActionButtonAndPopover>;
}

return image;
}

export default CustomEmojiWithDefaultPressableAction;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import type {FC} from 'react';
import {Platform} from 'react-native';
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html';
import type {SvgProps} from 'react-native-svg';
import GlobalCreateIcon from '@assets/images/customEmoji/global-create.svg';
import CustomEmojiWithDefaultPressableAction from '@components/HTMLEngineProvider/CustomEmojiWithDefaultPressableAction';
import ImageSVG from '@components/ImageSVG';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';

// eslint-disable-next-line rulesdir/no-inline-named-export
export const emojiMap: Record<string, FC<SvgProps>> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let us minimize the lint overrides

Suggested change
export const emojiMap: Record<string, FC<SvgProps>> = {
const emojiMap: Record<string, FC<SvgProps>> = {

// eslint-disable-next-line @typescript-eslint/naming-convention
'action-menu-icon': GlobalCreateIcon,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'action-menu-icon': GlobalCreateIcon,
'actionmenuicon': GlobalCreateIcon,

};

function CustomEmojiRenderer({tnode}: CustomRendererProps<TText | TPhrasing>) {
const styles = useThemeStyles();
const emojiKey = tnode.attributes.emoji;
const positionFix = Platform.OS !== 'web' && {height: '5%'};
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand how restricting the height of the View moves its position on iOS. When I give a background color to the View with this styling the View appears very small and the image overflows but somehow it changes position. Can you please explain this? I have a suggestion using margin in styles/index as specified below which completely removes positionFix. Please check this and see if it is preferable.


if (emojiMap[emojiKey]) {
if ('pressablewithdefaultaction' in tnode.attributes) {
return <CustomEmojiWithDefaultPressableAction emojiKey={emojiKey} />;
}

return (
<ImageSVG
style={[styles.customEmoji, positionFix]}
src={emojiMap[emojiKey]}
width={variables.iconSizeNormal}
height={variables.iconSizeNormal}
/>
);
}
return null;
}

export default CustomEmojiRenderer;
2 changes: 2 additions & 0 deletions src/components/HTMLEngineProvider/HTMLRenderers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {CustomTagRendererRecord} from 'react-native-render-html';
import AnchorRenderer from './AnchorRenderer';
import CodeRenderer from './CodeRenderer';
import CustomEmojiRenderer from './CustomEmojiRenderer';
import DeletedActionRenderer from './DeletedActionRenderer';
import EditedRenderer from './EditedRenderer';
import EmojiRenderer from './EmojiRenderer';
Expand Down Expand Up @@ -29,6 +30,7 @@ const HTMLEngineProviderComponentList: CustomTagRendererRecord = {
'mention-user': MentionUserRenderer,
'mention-report': MentionReportRenderer,
'mention-here': MentionHereRenderer,
'custom-emoji': CustomEmojiRenderer,
emoji: EmojiRenderer,
'next-step-email': NextStepEmailRenderer,
'deleted-action': DeletedActionRenderer,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6412,6 +6412,7 @@ function buildOptimisticTaskReport(
description?: string,
policyID: string = CONST.POLICY.OWNER_EMAIL_FAKE,
notificationPreference: NotificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
shouldEscapeText?: boolean,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
shouldEscapeText?: boolean,
shouldEscapeText = true,

parse of ExpensiMark uses true as default for shouldEscapeText. So, let us default this to true and override it only when required.

): OptimisticTaskReport {
const participants: Participants = {
[ownerAccountID]: {
Expand All @@ -6426,7 +6427,7 @@ function buildOptimisticTaskReport(
return {
reportID: generateReportID(),
reportName: title,
description: getParsedComment(description ?? ''),
description: getParsedComment(description ?? '', {shouldEscapeText}),
ownerAccountID,
participants,
managerID: assigneeAccountID,
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,7 @@ function prepareOnboardingOptimisticData(
taskDescription,
targetChatPolicyID,
CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
false,
);
const emailCreatingAction =
engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? allPersonalDetails?.[actorAccountID]?.login ?? CONST.EMAIL.CONCIERGE : CONST.EMAIL.CONCIERGE;
Expand Down
Loading
Loading