mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
fix: remove field truncate logic (#1940)
Remove the truncation logic and render the text for preview/edit mode. Text will now overflow, but it's up to the user to correct it
This commit is contained in:
@ -227,19 +227,8 @@ export const DocumentSigningTextField = ({
|
|||||||
|
|
||||||
const parsedField = field.fieldMeta ? ZTextFieldMeta.parse(field.fieldMeta) : undefined;
|
const parsedField = field.fieldMeta ? ZTextFieldMeta.parse(field.fieldMeta) : undefined;
|
||||||
|
|
||||||
const labelDisplay =
|
const labelDisplay = parsedField?.label;
|
||||||
parsedField?.label && parsedField.label.length < 20
|
const textDisplay = parsedField?.text;
|
||||||
? parsedField.label
|
|
||||||
: parsedField?.label
|
|
||||||
? parsedField?.label.substring(0, 20) + '...'
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const textDisplay =
|
|
||||||
parsedField?.text && parsedField.text.length < 20
|
|
||||||
? parsedField.text
|
|
||||||
: parsedField?.text
|
|
||||||
? parsedField?.text.substring(0, 20) + '...'
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const fieldDisplayName = labelDisplay ? labelDisplay : textDisplay;
|
const fieldDisplayName = labelDisplay ? labelDisplay : textDisplay;
|
||||||
const charactersRemaining = (parsedFieldMeta?.characterLimit ?? 0) - (localText.length ?? 0);
|
const charactersRemaining = (parsedFieldMeta?.characterLimit ?? 0) - (localText.length ?? 0);
|
||||||
|
|||||||
@ -160,14 +160,14 @@ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let textToDisplay = fieldMeta?.label || _(FRIENDLY_FIELD_TYPE[type]) || '';
|
const labelToDisplay = fieldMeta?.label || _(FRIENDLY_FIELD_TYPE[type]) || '';
|
||||||
|
let textToDisplay: string | undefined;
|
||||||
|
|
||||||
const isSignatureField =
|
const isSignatureField =
|
||||||
field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE;
|
field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE;
|
||||||
|
|
||||||
// Trim default labels.
|
if (field.type === FieldType.TEXT && field.fieldMeta?.type === 'text' && field.fieldMeta?.text) {
|
||||||
if (textToDisplay.length > 20) {
|
textToDisplay = field.fieldMeta.text;
|
||||||
textToDisplay = textToDisplay.substring(0, 20) + '...';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.inserted) {
|
if (field.inserted) {
|
||||||
@ -190,18 +190,19 @@ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => {
|
|||||||
const textAlign = fieldMeta && 'textAlign' in fieldMeta ? fieldMeta.textAlign : 'left';
|
const textAlign = fieldMeta && 'textAlign' in fieldMeta ? fieldMeta.textAlign : 'left';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className="flex h-full w-full items-center overflow-hidden">
|
||||||
className={cn(
|
<p
|
||||||
'text-field-card-foreground flex h-full w-full items-center justify-center gap-x-1.5 overflow-clip whitespace-nowrap text-center text-[clamp(0.07rem,25cqw,0.825rem)]',
|
className={cn(
|
||||||
{
|
'text-foreground w-full whitespace-pre-wrap text-left text-[clamp(0.07rem,25cqw,0.825rem)] duration-200',
|
||||||
// Using justify instead of align because we also vertically center the text.
|
{
|
||||||
'justify-start': field.inserted && !isSignatureField && textAlign === 'left',
|
'!text-center': textAlign === 'center' || !textToDisplay,
|
||||||
'justify-end': field.inserted && !isSignatureField && textAlign === 'right',
|
'!text-right': textAlign === 'right',
|
||||||
'font-signature text-[clamp(0.07rem,25cqw,1.125rem)]': isSignatureField,
|
'font-signature text-[clamp(0.07rem,25cqw,1.125rem)]': isSignatureField,
|
||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{textToDisplay}
|
{textToDisplay || labelToDisplay}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user