Skip to content

Commit fb8771e

Browse files
authored
Merge pull request #92142 from Expensify/claude-systemMessagesSelectable
Make system/violation messages text-selectable on desktop web
2 parents e05d40a + b613869 commit fb8771e

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

src/components/InlineSystemMessage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
2+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
23
import useTheme from '@hooks/useTheme';
34
import useThemeStyles from '@hooks/useThemeStyles';
45

6+
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
7+
58
import React from 'react';
69
import {View} from 'react-native';
710

@@ -16,7 +19,9 @@ type InlineSystemMessageProps = {
1619
function InlineSystemMessage({message = ''}: InlineSystemMessageProps) {
1720
const theme = useTheme();
1821
const styles = useThemeStyles();
22+
const {shouldUseNarrowLayout} = useResponsiveLayout();
1923
const icons = useMemoizedLazyExpensifyIcons(['Exclamation']);
24+
const selectableStyle = !canUseTouchScreen() || !shouldUseNarrowLayout ? styles.userSelectText : styles.userSelectNone;
2025
if (!message) {
2126
return null;
2227
}
@@ -27,7 +32,7 @@ function InlineSystemMessage({message = ''}: InlineSystemMessageProps) {
2732
src={icons.Exclamation}
2833
fill={theme.danger}
2934
/>
30-
<Text style={styles.inlineSystemMessage}>{message}</Text>
35+
<Text style={[styles.inlineSystemMessage, selectableStyle]}>{message}</Text>
3136
</View>
3237
);
3338
}

src/components/ReportActionItem/TaskAction.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import RenderHTML from '@components/RenderHTML';
22
import Text from '@components/Text';
33

44
import useLocalize from '@hooks/useLocalize';
5+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
56
import useThemeStyles from '@hooks/useThemeStyles';
67

8+
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
79
import {getTaskReportActionMessage} from '@libs/TaskUtils';
810

911
import type {ReportAction} from '@src/types/onyx';
@@ -21,14 +23,20 @@ type TaskActionProps = {
2123
function TaskAction({action}: TaskActionProps) {
2224
const styles = useThemeStyles();
2325
const {translate} = useLocalize();
26+
const {shouldUseNarrowLayout} = useResponsiveLayout();
2427
const message = getTaskReportActionMessage(translate, action);
28+
const isSelectable = !canUseTouchScreen() || !shouldUseNarrowLayout;
29+
const selectableStyle = isSelectable ? styles.userSelectText : styles.userSelectNone;
2530

2631
return (
2732
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.breakWord, styles.preWrap]}>
2833
{message.html ? (
29-
<RenderHTML html={`<comment><muted-text>${message.html}</muted-text></comment>`} />
34+
<RenderHTML
35+
html={`<comment><muted-text>${message.html}</muted-text></comment>`}
36+
isSelectable={isSelectable}
37+
/>
3038
) : (
31-
<Text style={[styles.chatItemMessage, styles.colorMuted]}>{message.text}</Text>
39+
<Text style={[styles.chatItemMessage, styles.colorMuted, selectableStyle]}>{message.text}</Text>
3240
)}
3341
</View>
3442
);

src/pages/inbox/report/ReportActionItemBasicMessage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Text from '@components/Text';
22

3+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
34
import useThemeStyles from '@hooks/useThemeStyles';
45

6+
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
57
import {containsCustomEmoji, containsOnlyCustomEmoji} from '@libs/EmojiUtils';
68

79
import type ChildrenProps from '@src/types/utils/ChildrenProps';
@@ -18,19 +20,21 @@ type ReportActionItemBasicMessageProps = Partial<ChildrenProps> & {
1820

1921
function ReportActionItemBasicMessage({message, children}: ReportActionItemBasicMessageProps) {
2022
const styles = useThemeStyles();
23+
const {shouldUseNarrowLayout} = useResponsiveLayout();
2124
const messageContainsCustomEmojiWithText = useMemo(() => containsCustomEmoji(message) && !containsOnlyCustomEmoji(message), [message]);
25+
const selectableStyle = !canUseTouchScreen() || !shouldUseNarrowLayout ? styles.userSelectText : styles.userSelectNone;
2226

2327
return (
2428
<View>
2529
{!!message &&
2630
(messageContainsCustomEmojiWithText ? (
2731
<TextWithEmojiFragment
2832
message={Str.htmlDecode(message)}
29-
style={[styles.chatItemMessage, styles.colorMuted]}
33+
style={[styles.chatItemMessage, styles.colorMuted, selectableStyle]}
3034
alignCustomEmoji
3135
/>
3236
) : (
33-
<Text style={[styles.chatItemMessage, styles.colorMuted]}>{Str.htmlDecode(message)}</Text>
37+
<Text style={[styles.chatItemMessage, styles.colorMuted, selectableStyle]}>{Str.htmlDecode(message)}</Text>
3438
))}
3539
{children}
3640
</View>

src/pages/inbox/report/ReportActionItemMessageWithExplain.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import useDelegateAccountID from '@hooks/useDelegateAccountID';
66
import useEnvironment from '@hooks/useEnvironment';
77
import useLocalize from '@hooks/useLocalize';
88
import useOnyx from '@hooks/useOnyx';
9+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
910

1011
import {openLink} from '@libs/actions/Link';
1112
import {explain} from '@libs/actions/Report';
13+
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
1214
import {getParticipantsPersonalDetails} from '@libs/PersonalDetailsUtils';
1315
import {hasReasoning} from '@libs/ReportActionsUtils';
1416

@@ -46,6 +48,7 @@ function ReportActionItemMessageWithExplain({message, action, childReport, origi
4648
const {translate} = useLocalize();
4749
const personalDetail = useCurrentUserPersonalDetails();
4850
const {environmentURL} = useEnvironment();
51+
const {shouldUseNarrowLayout} = useResponsiveLayout();
4952
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
5053
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
5154
const [betas] = useOnyx(ONYXKEYS.BETAS);
@@ -83,7 +86,7 @@ function ReportActionItemMessageWithExplain({message, action, childReport, origi
8386
<ReportActionItemBasicMessage>
8487
<RenderHTML
8588
html={`<comment><muted-text>${computedMessage}</muted-text></comment>`}
86-
isSelectable={false}
89+
isSelectable={!canUseTouchScreen() || !shouldUseNarrowLayout}
8790
onLinkPress={handleLinkPress}
8891
/>
8992
</ReportActionItemBasicMessage>

0 commit comments

Comments
 (0)