Skip to content

Commit 10bd397

Browse files
committed
[web] fix user profile long username bug
Summary: This diff fixes the bug where we had text overflow with longer usernames. To address this I introduced a version of `SingleLine` for `web`. For context here is the `native` version of `SingleLine` https://github.com/CommE2E/comm/blob/master/native/components/single-line.react.js Linear task: https://linear.app/comm/issue/ENG-5372/fix-user-profiles-for-long-usernames Test Plan: Please see screenshots below Before: {F837885} after: {F837886} Reviewers: atul, inka Reviewed By: atul Subscribers: ted, ashoat, tomek, wyilio Differential Revision: https://phab.comm.dev/D9604
1 parent 2957186 commit 10bd397

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

web/components/single-line.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.singleLine {
2+
white-space: nowrap;
3+
overflow: hidden;
4+
text-overflow: ellipsis;
5+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @flow
2+
3+
import classNames from 'classnames';
4+
import * as React from 'react';
5+
6+
import { firstLine } from 'lib/utils/string-utils.js';
7+
8+
import css from './single-line.css';
9+
10+
type Props = {
11+
+children: string,
12+
+className?: string,
13+
};
14+
15+
function SingleLine(props: Props): React.Node {
16+
const { children, className } = props;
17+
18+
const text = firstLine(children);
19+
20+
const singleLineClassName = classNames([css.singleLine, className]);
21+
22+
return <div className={singleLineClassName}>{text}</div>;
23+
}
24+
25+
export default SingleLine;

web/modals/user-profile/user-profile.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
}
1616

1717
.usernameContainer {
18-
padding-left: 16px;
18+
margin-left: 16px;
19+
overflow: hidden;
1920
}
2021

2122
.usernameText {

web/modals/user-profile/user-profile.react.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import UserProfileActionButtons from './user-profile-action-buttons.react.js';
1414
import UserProfileAvatarModal from './user-profile-avatar-modal.react.js';
1515
import css from './user-profile.css';
1616
import UserAvatar from '../../avatars/user-avatar.react.js';
17+
import SingleLine from '../../components/single-line.react.js';
1718

1819
type Props = {
1920
+userInfo: ?UserInfo,
@@ -65,7 +66,7 @@ function UserProfile(props: Props): React.Node {
6566
<UserAvatar userID={userInfo?.id} size="L" />
6667
</div>
6768
<div className={css.usernameContainer}>
68-
<div className={css.usernameText}>{usernameText}</div>
69+
<SingleLine className={css.usernameText}>{usernameText}</SingleLine>
6970
<div
7071
className={css.copyUsernameContainer}
7172
onClick={onClickCopyUsername}

0 commit comments

Comments
 (0)