Skip to content

Commit

Permalink
fix: middle-truncate editable text field
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschreiber committed Nov 30, 2023
1 parent df6637a commit b045686
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/common/components/EditableText.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
Typography,
} from '@mui/material';

import MiddleEllipsis from 'common/components/MiddleEllipsis';

const EditableText = props => {
const { t } = useTranslation();
const {
Expand All @@ -36,6 +38,7 @@ const EditableText = props => {
processing,
addMessage,
viewProps,
truncateLongNames,
onSave,
isEditing,
setIsEditing,
Expand Down Expand Up @@ -133,6 +136,14 @@ const EditableText = props => {
);
}

const textValue = truncateLongNames ? (
<MiddleEllipsis>
<Typography component="span">{value}</Typography>
</MiddleEllipsis>
) : (
value
);

return (
<Typography
component={Stack}
Expand All @@ -154,7 +165,7 @@ const EditableText = props => {
...(viewProps?.sx || {}),
}}
>
{value || <Link href="#">+ {addMessage}</Link>}
{textValue || <Link href="#">+ {addMessage}</Link>}
{isHovering && <EditIcon sx={{ color: 'blue.dark' }} />}
</Typography>
);
Expand Down
6 changes: 5 additions & 1 deletion src/sharedData/components/SharedDataEntryBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,15 @@ const SharedDataEntryBase = props => {
id={`name-${dataEntry.id}`}
label={t('sharedData.name_update')}
value={dataEntry.name}
truncateLongNames={true}
onSave={onUpdateName}
processing={processing}
isEditing={isEditingName}
setIsEditing={setIsEditingName}
viewProps={{ color: 'black', sx: { flexGrow: 1 } }}
viewProps={{
color: 'black',
sx: { flexGrow: 1, overflow: 'hidden' },
}}
/>
</Restricted>
</Grid>
Expand Down

0 comments on commit b045686

Please sign in to comment.