[AI] Fix record chips not rendering inside markdown tables in AI chat (#19260)
closes https://discord.com/channels/1130383047699738754/1480976327204016131 before - <img width="778" height="1259" alt="CleanShot 2026-04-02 at 18 33 03" src="https://github.com/user-attachments/assets/66ee2fc7-a116-458e-86a6-2aa6806b9407" /> after - <img width="758" height="1291" alt="CleanShot 2026-04-02 at 18 32 21" src="https://github.com/user-attachments/assets/9e303ff5-d8f4-4c9e-83e7-9a8e6427673a" />
This commit is contained in:
@@ -10,7 +10,13 @@ import {
|
||||
StyledSkeletonContainer,
|
||||
StyledTableScrollContainer,
|
||||
} from '@/ai/components/LazyMarkdownRendererStyledComponents';
|
||||
import { lazy, Suspense, useContext } from 'react';
|
||||
import {
|
||||
cloneElement,
|
||||
isValidElement,
|
||||
lazy,
|
||||
Suspense,
|
||||
useContext,
|
||||
} from 'react';
|
||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { ThemeContext } from 'twenty-ui/theme-constants';
|
||||
@@ -64,6 +70,16 @@ const processChildrenForRecordLinks = (
|
||||
));
|
||||
}
|
||||
|
||||
if (isValidElement<{ children?: React.ReactNode }>(children)) {
|
||||
const childProps = children.props;
|
||||
|
||||
if (isDefined(childProps.children)) {
|
||||
return cloneElement(children, {
|
||||
children: processChildrenForRecordLinks(childProps.children),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
@@ -96,6 +112,12 @@ const MarkdownRenderer = lazy(async () => {
|
||||
{processChildrenForRecordLinks(children)}
|
||||
</ParagraphComponent>
|
||||
),
|
||||
td: ({ children }) => (
|
||||
<td>{processChildrenForRecordLinks(children)}</td>
|
||||
),
|
||||
th: ({ children }) => (
|
||||
<th>{processChildrenForRecordLinks(children)}</th>
|
||||
),
|
||||
li: ({ children }) => (
|
||||
<li>{processChildrenForRecordLinks(children)}</li>
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user