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

[CP Staging] added component #30081

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
32 changes: 32 additions & 0 deletions src/components/ZeroWidthComponent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as EmojiUtils from '../../libs/EmojiUtils';
import * as Browser from '../../libs/Browser';
import Text from '../Text';

const propTypes = {
/** If this is the Concierge chat, we'll open the modal for requesting a setup call instead of showing popover menu */
text: PropTypes.string,

/** URL to the assigned guide's appointment booking calendar */
displayAsGroup: PropTypes.bool,
};

const defaultProps = {
text: '',
displayAsGroup: false,
};

function ZeroWidthComponent({text, displayAsGroup}) {
const firstLetterIsEmoji = EmojiUtils.isFirstLetterEmoji(text);
if (firstLetterIsEmoji && !displayAsGroup && !Browser.isMobile()) {
return <Text>&#x200b;</Text>;
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 see import for Text tag

}
return null;
}

ZeroWidthComponent.propTypes = propTypes;
ZeroWidthComponent.defaultProps = defaultProps;
ZeroWidthComponent.displayName = 'ZeroWidthComponent';

export default ZeroWidthComponent;
3 changes: 3 additions & 0 deletions src/components/ZeroWidthComponent/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const checkForEmojiForSelection = () => null;

export default checkForEmojiForSelection;
25 changes: 5 additions & 20 deletions src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import CONST from '../../../CONST';
import editedLabelStyles from '../../../styles/editedLabelStyles';
import UserDetailsTooltip from '../../../components/UserDetailsTooltip';
import avatarPropTypes from '../../../components/avatarPropTypes';
import * as Browser from '../../../libs/Browser';
import ZeroWidthComponent from '../../../components/ZeroWidthComponent';

const propTypes = {
/** Users accountID */
Expand Down Expand Up @@ -90,24 +90,6 @@ const defaultProps = {
};

function ReportActionItemFragment(props) {
/**
* Checks text element for presence of emoji as first character
* and insert Zero-Width character to avoid selection issue
* mentioned here https://github.com/Expensify/App/issues/29021
*
* @param {String} text
* @param {Boolean} displayAsGroup
* @returns {ReactNode | null} Text component with zero width character
*/

const checkForEmojiForSelection = (text, displayAsGroup) => {
const firstLetterIsEmoji = EmojiUtils.isFirstLetterEmoji(text);
if (firstLetterIsEmoji && !displayAsGroup && !Browser.isMobile()) {
return <Text>&#x200b;</Text>;
}
return null;
};

switch (props.fragment.type) {
case 'COMMENT': {
const {html, text} = props.fragment;
Expand Down Expand Up @@ -139,7 +121,10 @@ function ReportActionItemFragment(props) {

return (
<Text style={[containsOnlyEmojis ? styles.onlyEmojisText : undefined, styles.ltr, ...props.style]}>
{checkForEmojiForSelection(text, props.displayAsGroup)}
<ZeroWidthComponent
Copy link
Contributor

Choose a reason for hiding this comment

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

this is breaking web
Screenshot 2023-10-20 at 16 37 48

Copy link
Contributor

Choose a reason for hiding this comment

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

text={text}
displayAsGroup={props.displayAsGroup}
/>
<Text
selectable={!DeviceCapabilities.canUseTouchScreen() || !props.isSmallScreenWidth}
style={[containsOnlyEmojis ? styles.onlyEmojisText : undefined, styles.ltr, ...props.style, isPendingDelete ? styles.offlineFeedback.deleted : undefined]}
Expand Down