From 3b88a07ddece4d8d7b6a1210f284e84838e4afb6 Mon Sep 17 00:00:00 2001 From: DragonBot00 Date: Wed, 1 Apr 2026 14:39:07 -0500 Subject: [PATCH] fix: strip HTML tags from note values in alert table columns (fixes #5283) --- .../alerts-table/lib/alert-table-utils.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx b/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx index 66b8b88114..579dae7fd6 100644 --- a/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx +++ b/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx @@ -188,6 +188,15 @@ export const getCellClassName = ( const columnHelper = createColumnHelper(); +/** + * Strips HTML tags from a string, returning plain text. + * Used to display note values (saved via a rich-text editor) as plain text + * in alert table columns. + */ +const stripHtml = (html: string): string => { + return html.replace(/<[^>]*>/g, " ").replace(/\s{2,}/g, " ").trim(); +}; + interface GenerateAlertTableColsArg { additionalColsToGenerate?: string[]; isCheckboxDisplayed?: boolean; @@ -344,6 +353,13 @@ export const useAlertTableCols = ( } if (value) { + // Strip HTML tags from note values — notes are saved by a rich-text + // editor (Quill) which wraps content in HTML tags like

...

. + // Table columns should display plain text only. + const displayValue = + context.column.id === "note" && typeof value === "string" + ? stripHtml(value) + : value.toString(); return (
- {value.toString()} + {displayValue}
); }