Field name is oddly displayed when long (#6755)

### Description

- we added a new styled component to handle the label styles
- we added the title prop, and this will be applied for all fields,
track the styles and only adding the title if the label is hidden would
add unnecessary complexity to this issue, let us know if It's fine
- On our internal QA review, we noticed this extra error in the name:\
when we have spaces between the characters on names the name is
displayed in a weird way


![](https://assets-service.gitstart.com/28455/b3933bec-f5ec-48b9-a627-744507bc9fad.png)

when we don't have spaces we use the space on the right to fit the full
name\
like this:


![](https://assets-service.gitstart.com/28455/77aec9d1-7875-4164-b2ce-97ccee7fb25e.png)Do
you want us to fix this problem too?

when testing the new changes since we changed one component that is used
on the main pages we created objects with a big name, to test the header
on the table view, and we noticed that the object name has exactly the
same issue as the field name on the settings page.


!\[image\](<https://github.com/user-attachments/assets/cfa3a0a3-da98-4b09-9650-178ace05bcbf>)

we added a fix for new field creation if the object name is long


![](https://assets-service.gitstart.com/28455/99faef48-99b4-480e-ae6d-71aa40030434.png)###
Refs

#6738

### Demo


<https://www.loom.com/share/3572fb0c4e994b0aaac52985e76ae4fd?sid=9ef177e2-827b-45f2-8083-60771eef6203>

Fixes #6738

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
This commit is contained in:
gitstart-app[bot]
2024-09-03 15:07:45 +02:00
committed by GitHub
parent bc2227ddbb
commit 8f65326b47
7 changed files with 70 additions and 14 deletions

View File

@ -48,6 +48,12 @@ const StyledNameTableCell = styled(TableCell)`
gap: ${({ theme }) => theme.spacing(2)};
`;
const StyledNameLabel = styled.div`
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
`;
const StyledIconTableCell = styled(TableCell)`
justify-content: center;
padding-right: ${({ theme }) => theme.spacing(1)};
@ -203,9 +209,15 @@ export const SettingsObjectFieldItemTableRow = ({
>
<StyledNameTableCell>
{!!Icon && (
<Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
<Icon
style={{ minWidth: theme.icon.size.md }}
size={theme.icon.size.md}
stroke={theme.icon.stroke.sm}
/>
)}
{fieldMetadataItem.label}
<StyledNameLabel title={fieldMetadataItem.label}>
{fieldMetadataItem.label}
</StyledNameLabel>
</StyledNameTableCell>
<TableCell>{typeLabel}</TableCell>
<TableCell>

View File

@ -25,6 +25,12 @@ const StyledNameTableCell = styled(TableCell)`
gap: ${({ theme }) => theme.spacing(2)};
`;
const StyledNameLabel = styled.div`
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
`;
const StyledActionTableCell = styled(TableCell)`
justify-content: center;
padding-right: ${({ theme }) => theme.spacing(1)};
@ -46,9 +52,15 @@ export const SettingsObjectMetadataItemTableRow = ({
<StyledObjectTableRow key={objectMetadataItem.namePlural} to={link}>
<StyledNameTableCell>
{!!Icon && (
<Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
<Icon
style={{ minWidth: theme.icon.size.md }}
size={theme.icon.size.md}
stroke={theme.icon.stroke.sm}
/>
)}
{objectMetadataItem.labelPlural}
<StyledNameLabel title={objectMetadataItem.labelPlural}>
{objectMetadataItem.labelPlural}
</StyledNameLabel>
</StyledNameTableCell>
<TableCell>
<SettingsDataModelObjectTypeTag objectTypeLabel={objectTypeLabel} />