Skip to content

Commit bddcf52

Browse files
fix: custom status text wrap in drawer (#6778)
Co-authored-by: Diego Mello <[email protected]>
1 parent b55299e commit bddcf52

File tree

4 files changed

+119
-5
lines changed

4 files changed

+119
-5
lines changed

app/containers/List/List.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export const TitleAndSubtitle = () => (
2121
<List.Separator />
2222
<List.Item title={longText} subtitle={longText} translateTitle={false} translateSubtitle={false} testID='test-id' />
2323
<List.Separator />
24+
<List.Item title={longText} subtitle={longText} translateTitle={false} translateSubtitle={false} numberOfLines={1} />
25+
<List.Separator />
2426
</List.Container>
2527
);
2628

app/containers/List/ListItem.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ const styles = StyleSheet.create({
6262
}
6363
});
6464

65-
interface IListTitle extends Pick<IListItemContent, 'title' | 'color' | 'translateTitle' | 'styleTitle'> {}
65+
interface IListTitle extends Pick<IListItemContent, 'title' | 'color' | 'translateTitle' | 'styleTitle' | 'numberOfLines'> {}
6666

67-
const ListTitle = ({ title, color, styleTitle, translateTitle }: IListTitle) => {
67+
const ListTitle = ({ title, color, styleTitle, translateTitle, numberOfLines }: IListTitle) => {
6868
'use memo';
6969

7070
const { colors } = useTheme();
7171
switch (typeof title) {
7272
case 'string':
7373
return (
74-
<Text style={[styles.title, styleTitle, { color: color || colors.fontDefault }]}>
74+
<Text numberOfLines={numberOfLines} style={[styles.title, styleTitle, { color: color || colors.fontDefault }]}>
7575
{translateTitle && title ? I18n.t(title) : title}
7676
</Text>
7777
);
@@ -102,6 +102,7 @@ interface IListItemContent {
102102
additionalAcessibilityLabel?: string | boolean;
103103
accessibilityRole?: AccessibilityRole;
104104
additionalAcessibilityLabelCheck?: boolean;
105+
numberOfLines?: number;
105106
}
106107

107108
const Content = React.memo(
@@ -123,7 +124,8 @@ const Content = React.memo(
123124
additionalAcessibilityLabel,
124125
additionalAcessibilityLabelCheck,
125126
accessibilityRole,
126-
accessibilityLabel
127+
accessibilityLabel,
128+
numberOfLines
127129
}: IListItemContent) => {
128130
'use memo';
129131

@@ -165,7 +167,15 @@ const Content = React.memo(
165167
{title || subtitle ? (
166168
<View style={styles.textContainer}>
167169
<View style={styles.textAlertContainer}>
168-
{title ? <ListTitle title={title} color={color} styleTitle={styleTitle} translateTitle={translateTitle} /> : null}
170+
{title ? (
171+
<ListTitle
172+
title={title}
173+
color={color}
174+
styleTitle={styleTitle}
175+
translateTitle={translateTitle}
176+
numberOfLines={numberOfLines}
177+
/>
178+
) : null}
169179
{alert ? (
170180
<CustomIcon name='info' size={ICON_SIZE} color={colors.buttonBackgroundDangerDefault} style={styles.alertIcon} />
171181
) : null}

app/containers/List/__snapshots__/List.test.tsx.snap

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,107 @@ exports[`Story Snapshots: TitleAndSubtitle should match snapshot 1`] = `
24692469
]
24702470
}
24712471
/>
2472+
<View
2473+
style={
2474+
{
2475+
"backgroundColor": "#FFFFFF",
2476+
}
2477+
}
2478+
>
2479+
<View
2480+
accessibilityLabel="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
2481+
accessibilityRole="button"
2482+
accessible={true}
2483+
style={
2484+
[
2485+
{
2486+
"alignItems": "center",
2487+
"flex": 1,
2488+
"flexDirection": "row",
2489+
"justifyContent": "center",
2490+
"paddingHorizontal": 12,
2491+
},
2492+
undefined,
2493+
{
2494+
"height": 46,
2495+
},
2496+
]
2497+
}
2498+
>
2499+
<View
2500+
style={
2501+
{
2502+
"flex": 1,
2503+
"justifyContent": "center",
2504+
}
2505+
}
2506+
>
2507+
<View
2508+
style={
2509+
{
2510+
"alignItems": "center",
2511+
"flexDirection": "row",
2512+
}
2513+
}
2514+
>
2515+
<Text
2516+
numberOfLines={1}
2517+
style={
2518+
[
2519+
{
2520+
"backgroundColor": "transparent",
2521+
"flex": 1,
2522+
"flexShrink": 1,
2523+
"fontFamily": "Inter",
2524+
"fontSize": 16,
2525+
"fontWeight": "500",
2526+
"textAlign": "left",
2527+
},
2528+
undefined,
2529+
{
2530+
"color": "#2F343D",
2531+
},
2532+
]
2533+
}
2534+
>
2535+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
2536+
</Text>
2537+
</View>
2538+
<Text
2539+
numberOfLines={1}
2540+
style={
2541+
[
2542+
{
2543+
"backgroundColor": "transparent",
2544+
"fontFamily": "Inter",
2545+
"fontSize": 14,
2546+
"fontWeight": "400",
2547+
"textAlign": "left",
2548+
},
2549+
{
2550+
"color": "#6C727A",
2551+
},
2552+
]
2553+
}
2554+
>
2555+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
2556+
</Text>
2557+
</View>
2558+
</View>
2559+
</View>
2560+
<View
2561+
style={
2562+
[
2563+
{
2564+
"height": 0.5,
2565+
},
2566+
undefined,
2567+
{
2568+
"backgroundColor": "#CBCED1",
2569+
},
2570+
]
2571+
}
2572+
/>
24722573
</View>
24732574
</RCTScrollView>
24742575
`;

app/views/SidebarView/components/CustomStatus.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const CustomStatus = () => {
7272
onPress={() => (presenceBroadcastDisabled ? onPressPresenceLearnMore() : sidebarNavigate('StatusView'))}
7373
translateTitle={!statusText}
7474
testID={`sidebar-custom-status-${status}`}
75+
numberOfLines={1}
7576
/>
7677
<List.Separator />
7778
</>

0 commit comments

Comments
 (0)