diff --git a/client/components/Message/Attachments/DefaultAttachment.tsx b/client/components/Message/Attachments/DefaultAttachment.tsx index f67faa1540cd8..a49508de79b7d 100644 --- a/client/components/Message/Attachments/DefaultAttachment.tsx +++ b/client/components/Message/Attachments/DefaultAttachment.tsx @@ -18,6 +18,8 @@ export type DefaultAttachmentProps = { author_link?: string; author_name?: string; + // TODO: replace this component props type with a payload-based type because + // `value` comes as `string` and is passed as `ReactNode` fields: FieldsAttachmentProps; // footer @@ -57,7 +59,13 @@ export const DefaultAttachment: FC = (attachment) => { {!collapsed && <> {attachment.text && {applyMardownFor('text', attachment.text)}} {/* {attachment.fields && ({ ...rest, value: })) : attachment.fields} />} */} - {attachment.fields && { + {attachment.fields && { + if (!field.value) { + return field; + } + + const { value, ...rest } = field; + const cleanValue = (value as string).replace(/(.*)/g, (line: string) => { if (line.trim() === '') { return `${ line }
`; diff --git a/client/components/Message/Attachments/FieldsAttachment.tsx b/client/components/Message/Attachments/FieldsAttachment.tsx index 1c2ee56c6a4bb..6ab71bbe6798f 100644 --- a/client/components/Message/Attachments/FieldsAttachment.tsx +++ b/client/components/Message/Attachments/FieldsAttachment.tsx @@ -1,10 +1,10 @@ -import React, { FC } from 'react'; +import React, { FC, ReactNode } from 'react'; import { Box, BoxProps } from '@rocket.chat/fuselage'; type FieldProp = { short?: boolean; title: string; - value: JSX.Element | string; + value: ReactNode; } const Field: FC = ({ title, value, ...props }) =>