Skip to content

Commit 37f4949

Browse files
authored
fix: long usernames push timestamp and right icons out of view (#7109)
1 parent 8f2b70d commit 37f4949

5 files changed

Lines changed: 22157 additions & 21207 deletions

File tree

app/containers/message/Message.stories.tsx

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,22 @@ const author = {
2828
username: 'diego.mello'
2929
};
3030

31+
const shortNameAuthor = {
32+
_id: 'userid1',
33+
username: 'jd',
34+
name: 'JD'
35+
};
36+
37+
const mediumNameAuthor = {
38+
_id: 'userid2',
39+
username: 'john.doe',
40+
name: 'John Doe'
41+
};
42+
3143
const longNameAuthor = {
32-
_id: 'userid',
33-
username: 'Long name user looooong name user'
44+
_id: 'userid3',
45+
username: 'johndoeverylongusernamejohndoeverylongusernamejohndoeverylongusernamejohndoeverylongusernamejohndoeverylongusername',
46+
name: 'John Doe With An Extremely Long Display Name That Should Definitely Be Truncated In Any Reasonable User Interface Layout'
3447
};
3548

3649
const baseUrl = 'https://open.rocket.chat';
@@ -389,6 +402,91 @@ export const FullNameLargeFont = () => (
389402
/>
390403
);
391404

405+
export const Names = () => (
406+
<>
407+
<Message msg='Small name (2 chars)' author={shortNameAuthor} useRealName />
408+
<Message
409+
msg='Small name with icons'
410+
author={shortNameAuthor}
411+
useRealName
412+
isEdited
413+
isTranslated
414+
pinned
415+
type={E2E_MESSAGE_TYPE}
416+
hasError
417+
isReadReceiptEnabled
418+
read
419+
/>
420+
<Message msg='Medium name (8 chars)' author={mediumNameAuthor} useRealName />
421+
<Message
422+
msg='Medium name with icons'
423+
author={mediumNameAuthor}
424+
useRealName
425+
isEdited
426+
isTranslated
427+
pinned
428+
type={E2E_MESSAGE_TYPE}
429+
hasError
430+
isReadReceiptEnabled
431+
read
432+
/>
433+
<Message msg='Long name (22 chars) - should truncate' author={longNameAuthor} useRealName />
434+
<Message
435+
msg='Long name with icons - timestamp visible'
436+
author={longNameAuthor}
437+
useRealName
438+
isEdited
439+
isTranslated
440+
pinned
441+
type={E2E_MESSAGE_TYPE}
442+
hasError
443+
isReadReceiptEnabled
444+
read
445+
/>
446+
</>
447+
);
448+
449+
export const Usernames = () => (
450+
<>
451+
<Message msg='Small username (2 chars)' author={shortNameAuthor} />
452+
<Message
453+
msg='Small username with icons'
454+
author={shortNameAuthor}
455+
isEdited
456+
isTranslated
457+
pinned
458+
type={E2E_MESSAGE_TYPE}
459+
hasError
460+
isReadReceiptEnabled
461+
read
462+
/>
463+
<Message msg='Medium username (8 chars)' author={mediumNameAuthor} />
464+
<Message
465+
msg='Medium username with icons'
466+
author={mediumNameAuthor}
467+
isEdited
468+
isTranslated
469+
pinned
470+
type={E2E_MESSAGE_TYPE}
471+
hasError
472+
isReadReceiptEnabled
473+
read
474+
/>
475+
<Message msg='Long username (22 chars) - should truncate' author={longNameAuthor} />
476+
<Message
477+
msg='Long username with icons - timestamp visible'
478+
author={longNameAuthor}
479+
isEdited
480+
isTranslated
481+
pinned
482+
type={E2E_MESSAGE_TYPE}
483+
hasError
484+
isReadReceiptEnabled
485+
read
486+
/>
487+
</>
488+
);
489+
392490
const msgMentions = '@rocket.cat @diego.mello @all @here #general @team';
393491
const mentions = [
394492
{ _id: 'random', name: 'Rocket Cat', username: 'rocket.cat', type: 'user' },

app/containers/message/Time.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Text } from 'react-native';
2+
import { Text, type TextStyle } from 'react-native';
33

44
import dayjs from '../../lib/dayjs';
55
import { useTheme } from '../../theme';
@@ -8,16 +8,17 @@ import messageStyles from './styles';
88
interface IMessageTime {
99
ts?: Date;
1010
timeFormat?: string;
11+
style?: TextStyle;
1112
}
1213

13-
const MessageTime = ({ timeFormat, ts }: IMessageTime) => {
14+
const MessageTime = ({ timeFormat, ts, style }: IMessageTime) => {
1415
'use memo';
1516

1617
const { colors } = useTheme();
1718

1819
const time = dayjs(ts).format(timeFormat);
1920

20-
return <Text style={[messageStyles.time, { color: colors.fontSecondaryInfo }]}>{time}</Text>;
21+
return <Text style={[messageStyles.time, { color: colors.fontSecondaryInfo }, style]}>{time}</Text>;
2122
};
2223

2324
export default MessageTime;

app/containers/message/User.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from 'react';
2-
import { StyleSheet, Text, View } from 'react-native';
2+
import { Pressable, StyleSheet, Text, View } from 'react-native';
33

44
import { type MessageType, type MessageTypesValues, SubscriptionType } from '../../definitions';
55
import { useTheme } from '../../theme';
@@ -10,7 +10,6 @@ import MessageContext from './Context';
1010
import { messageHaveAuthorName } from './utils';
1111
import MessageTime from './Time';
1212
import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout';
13-
import Touch from '../Touch';
1413

1514
const styles = StyleSheet.create({
1615
container: {
@@ -117,12 +116,12 @@ const User = React.memo(
117116

118117
return (
119118
<View style={styles.container}>
120-
<Touch testID={`username-header-${username}`} style={styles.titleContainer} onPress={onUserPress}>
119+
<Pressable testID={`username-header-${username}`} style={styles.titleContainer} onPress={onUserPress}>
121120
<Text style={[styles.username, { color: colors.fontTitlesLabels }]} numberOfLines={1}>
122121
{textContent}
123122
</Text>
124123
{isLargeFontScale ? null : <MessageTime timeFormat={timeFormat} ts={ts} />}
125-
</Touch>
124+
</Pressable>
126125
<RightIcons
127126
type={type}
128127
isEdited={isEdited}

0 commit comments

Comments
 (0)