Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Nov 28, 2022
1 parent 9756b27 commit f78337d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ export const TableVisComponent = ({
const rawContent = sortedRows[rowIndex][columnId];
const colIndex = columns.findIndex((col) => col.id === columnId);
const column = columns[colIndex];
// use formatter to format raw content
// this can format url, date and percentage data
const htmlContent = column.formatter.convert(rawContent, 'html');
const formattedContent = (
// eslint-disable-next-line
<div dangerouslySetInnerHTML={{ __html: dompurify.sanitize(htmlContent) }} />
/*
* Justification for dangerouslySetInnerHTML:
* This is one of the visualizations which makes use of the HTML field formatters.
* Since these formatters produce raw HTML, this visualization needs to be able to render them as-is, relying
* on the field formatter to only produce safe HTML.
*/
<div dangerouslySetInnerHTML={{ __html: dompurify.sanitize(htmlContent) }} /> // eslint-disable-line react/no-danger
);
return sortedRows.hasOwnProperty(rowIndex) ? formattedContent || null : null;
}) as EuiDataGridProps['renderCellValue'];
Expand Down

0 comments on commit f78337d

Please sign in to comment.