Skip to content

Commit 1e6346f

Browse files
KarankhatikkarankhatikcharlesBochet
authored
[Fix] - Trim Names in Settings > Members table #7509 (#7525)
Issue: Long names in the Members table were overflowing, affecting the layout. Fix: - Trimmed long names with ellipses. - Added tooltips to display the full content on hover. - Max-width of the text dynamically set to 90px on large screens, and 60px on mobile. ![image](https://github.com/user-attachments/assets/3b5d1c08-fe0e-4c0b-952a-0fc0f9e513bc) --------- Co-authored-by: karankhatik <[email protected]> Co-authored-by: Charles Bochet <[email protected]>
1 parent 1e2c5bb commit 1e6346f

File tree

2 files changed

+61
-58
lines changed

2 files changed

+61
-58
lines changed

packages/twenty-front/src/modules/ui/layout/table/components/TableRow.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Link } from 'react-router-dom';
21
import isPropValid from '@emotion/is-prop-valid';
32
import styled from '@emotion/styled';
3+
import { Link } from 'react-router-dom';
4+
import { MOBILE_VIEWPORT } from 'twenty-ui';
45

56
const StyledTableRow = styled('div', {
67
shouldForwardProp: (prop) =>
@@ -10,12 +11,19 @@ const StyledTableRow = styled('div', {
1011
onClick?: () => void;
1112
to?: string;
1213
gridAutoColumns?: string;
14+
mobileGridAutoColumns?: string;
1315
}>`
1416
background-color: ${({ isSelected, theme }) =>
1517
isSelected ? theme.accent.quaternary : 'transparent'};
1618
border-radius: ${({ theme }) => theme.border.radius.sm};
1719
display: grid;
1820
grid-auto-columns: ${({ gridAutoColumns }) => gridAutoColumns ?? '1fr'};
21+
22+
@media (max-width: ${MOBILE_VIEWPORT}px) {
23+
grid-auto-columns: ${({ mobileGridAutoColumns, gridAutoColumns }) =>
24+
mobileGridAutoColumns ?? gridAutoColumns ?? '1fr'};
25+
}
26+
1927
grid-auto-flow: column;
2028
transition: background-color
2129
${({ theme }) => theme.animation.duration.normal}s;
@@ -35,6 +43,7 @@ type TableRowProps = {
3543
to?: string;
3644
className?: string;
3745
gridAutoColumns?: string;
46+
mobileGridAutoColumns?: string;
3847
};
3948

4049
export const TableRow = ({
@@ -44,12 +53,14 @@ export const TableRow = ({
4453
className,
4554
children,
4655
gridAutoColumns,
56+
mobileGridAutoColumns,
4757
}: React.PropsWithChildren<TableRowProps>) => (
4858
<StyledTableRow
4959
isSelected={isSelected}
5060
onClick={onClick}
5161
gridAutoColumns={gridAutoColumns}
5262
className={className}
63+
mobileGridAutoColumns={mobileGridAutoColumns}
5364
to={to}
5465
as={to ? Link : 'div'}
5566
>

packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx

+49-57
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { isNonEmptyArray } from '@sniptt/guards';
44
import { useState } from 'react';
55
import { useRecoilValue, useSetRecoilState } from 'recoil';
66
import {
7+
AppTooltip,
78
Avatar,
89
H2Title,
910
IconMail,
1011
IconReload,
1112
IconTrash,
12-
MOBILE_VIEWPORT,
13+
TooltipDelay,
1314
} from 'twenty-ui';
1415

1516
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
@@ -52,49 +53,20 @@ const StyledTable = styled(Table)`
5253
margin-top: ${({ theme }) => theme.spacing(0.5)};
5354
`;
5455

55-
const StyledTableRow = styled(TableRow)`
56-
@media (max-width: ${MOBILE_VIEWPORT}px) {
57-
display: grid;
58-
grid-template-columns: 3fr;
59-
}
60-
`;
61-
const StyledTableCell = styled(TableCell)`
62-
padding: ${({ theme }) => theme.spacing(1)};
63-
@media (max-width: ${MOBILE_VIEWPORT}px) {
64-
&:first-child {
65-
max-width: 100%;
66-
padding-top: 2px;
67-
white-space: nowrap;
68-
overflow: scroll;
69-
scroll-behavior: smooth;
70-
}
71-
}
56+
const StyledTableHeaderRow = styled(Table)`
57+
margin-bottom: ${({ theme }) => theme.spacing(1.5)};
7258
`;
59+
7360
const StyledIconWrapper = styled.div`
74-
left: 2px;
61+
display: flex;
62+
align-items: center;
7563
margin-right: ${({ theme }) => theme.spacing(2)};
76-
position: relative;
77-
top: 1px;
78-
`;
79-
80-
const StyledScrollableTextContainer = styled.div`
81-
max-width: 100%;
82-
overflow-x: auto;
83-
white-space: pre-line;
8464
`;
8565

86-
const StyledTextContainer = styled.div`
87-
color: ${({ theme }) => theme.font.color.secondary};
88-
max-width: max-content;
89-
overflow-x: auto;
90-
position: absolute;
91-
@media (min-width: 360px) and (max-width: 420px) {
92-
max-width: 150px;
93-
margin-top: ${({ theme }) => theme.spacing(1)};
94-
}
95-
`;
96-
const StyledTableHeaderRow = styled(Table)`
97-
margin-bottom: ${({ theme }) => theme.spacing(1.5)};
66+
const StyledTextContainerWithEllipsis = styled.div`
67+
overflow: hidden;
68+
text-overflow: ellipsis;
69+
white-space: nowrap;
9870
`;
9971

10072
export const SettingsWorkspaceMembers = () => {
@@ -194,15 +166,21 @@ export const SettingsWorkspaceMembers = () => {
194166
/>
195167
<Table>
196168
<StyledTableHeaderRow>
197-
<TableRow>
169+
<TableRow
170+
gridAutoColumns="150px 1fr 1fr"
171+
mobileGridAutoColumns="100px 1fr 1fr"
172+
>
198173
<TableHeader>Name</TableHeader>
199174
<TableHeader>Email</TableHeader>
200175
<TableHeader align={'right'}></TableHeader>
201176
</TableRow>
202177
</StyledTableHeaderRow>
203178
{workspaceMembers?.map((workspaceMember) => (
204179
<StyledTable key={workspaceMember.id}>
205-
<TableRow>
180+
<TableRow
181+
gridAutoColumns="150px 1fr 1fr"
182+
mobileGridAutoColumns="100px 1fr 1fr"
183+
>
206184
<TableCell>
207185
<StyledIconWrapper>
208186
<Avatar
@@ -213,16 +191,26 @@ export const SettingsWorkspaceMembers = () => {
213191
size="sm"
214192
/>
215193
</StyledIconWrapper>
216-
<StyledScrollableTextContainer>
194+
<StyledTextContainerWithEllipsis
195+
id={`hover-text-${workspaceMember.id}`}
196+
>
217197
{workspaceMember.name.firstName +
218198
' ' +
219199
workspaceMember.name.lastName}
220-
</StyledScrollableTextContainer>
200+
</StyledTextContainerWithEllipsis>
201+
<AppTooltip
202+
anchorSelect={`#hover-text-${workspaceMember.id}`}
203+
content={`${workspaceMember.name.firstName} ${workspaceMember.name.lastName}`}
204+
noArrow
205+
place="top"
206+
positionStrategy="fixed"
207+
delay={TooltipDelay.shortDelay}
208+
/>
221209
</TableCell>
222210
<TableCell>
223-
<StyledTextContainer>
211+
<StyledTextContainerWithEllipsis>
224212
{workspaceMember.userEmail}
225-
</StyledTextContainer>
213+
</StyledTextContainerWithEllipsis>
226214
</TableCell>
227215
<TableCell align={'right'}>
228216
{currentWorkspaceMember?.id !== workspaceMember.id && (
@@ -253,35 +241,39 @@ export const SettingsWorkspaceMembers = () => {
253241
{isNonEmptyArray(workspaceInvitations) && (
254242
<Table>
255243
<StyledTableHeaderRow>
256-
<TableRow gridAutoColumns={`1fr 1fr ${theme.spacing(22)}`}>
244+
<TableRow
245+
gridAutoColumns="150px 1fr 1fr"
246+
mobileGridAutoColumns="100px 1fr 1fr"
247+
>
257248
<TableHeader>Email</TableHeader>
258249
<TableHeader align={'right'}>Expires in</TableHeader>
259250
<TableHeader></TableHeader>
260251
</TableRow>
261252
</StyledTableHeaderRow>
262253
{workspaceInvitations?.map((workspaceInvitation) => (
263254
<StyledTable key={workspaceInvitation.id}>
264-
<StyledTableRow
265-
gridAutoColumns={`1fr 1fr ${theme.spacing(22)}`}
255+
<TableRow
256+
gridAutoColumns="150px 1fr 1fr"
257+
mobileGridAutoColumns="100px 1fr 1fr"
266258
>
267-
<StyledTableCell>
259+
<TableCell>
268260
<StyledIconWrapper>
269261
<IconMail
270262
size={theme.icon.size.md}
271263
stroke={theme.icon.stroke.sm}
272264
/>
273265
</StyledIconWrapper>
274-
<StyledScrollableTextContainer>
266+
<StyledTextContainerWithEllipsis>
275267
{workspaceInvitation.email}
276-
</StyledScrollableTextContainer>
277-
</StyledTableCell>
278-
<StyledTableCell align={'right'}>
268+
</StyledTextContainerWithEllipsis>
269+
</TableCell>
270+
<TableCell align={'right'}>
279271
<Status
280272
color={'gray'}
281273
text={getExpiresAtText(workspaceInvitation.expiresAt)}
282274
/>
283-
</StyledTableCell>
284-
<StyledTableCell align={'right'}>
275+
</TableCell>
276+
<TableCell align={'right'}>
285277
<StyledButtonContainer>
286278
<IconButton
287279
onClick={() => {
@@ -304,8 +296,8 @@ export const SettingsWorkspaceMembers = () => {
304296
Icon={IconTrash}
305297
/>
306298
</StyledButtonContainer>
307-
</StyledTableCell>
308-
</StyledTableRow>
299+
</TableCell>
300+
</TableRow>
309301
</StyledTable>
310302
))}
311303
</Table>

0 commit comments

Comments
 (0)