Skip to content

Commit 2fc04de

Browse files
Aladexshahargl
andauthored
fix: prevent incident table horizontal overflow from long summaries (#6085)
Co-authored-by: Shahar Glazner <shaharglazner@gmail.com>
1 parent 88675eb commit 2fc04de

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

keep-ui/features/incidents/incident-list/ui/incidents-table.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,16 @@ export default function IncidentsTable({
196196
<FormattedContent
197197
content={summary}
198198
format="html"
199-
className="text-pretty overflow-hidden overflow-ellipsis line-clamp-3"
199+
plain
200+
className="line-clamp-2 text-sm text-gray-500"
200201
/>
201202
) : null}
202203
</div>
203204
);
204205
},
206+
meta: {
207+
tdClassName: "overflow-hidden",
208+
},
205209
}),
206210
columnHelper.accessor("alerts_count", {
207211
id: "alerts_count",

keep-ui/shared/ui/FormattedContent/FormattedContent.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,40 @@ function FormattedHTMLContent({
3838
);
3939
}
4040

41+
const stripHtmlTags = (html: string) => {
42+
return html.replace(/<[^>]*>/g, "").trim();
43+
};
44+
4145
interface FormattedContentProps {
4246
content: string | null | undefined;
4347
format?: "markdown" | "html" | null;
4448
className?: string;
49+
/**
50+
* When true, strips all HTML/markdown tags and renders as plain text.
51+
* Useful in table cells where line-clamp needs to work on inline text
52+
* without block-level elements (like <p>) breaking the clamp.
53+
*/
54+
plain?: boolean;
4555
}
4656

4757
export const FormattedContent: FC<FormattedContentProps> = ({
4858
content,
4959
format,
5060
className,
61+
plain,
5162
}) => {
5263
if (!content) {
5364
return null;
5465
}
5566

67+
if (plain) {
68+
return (
69+
<div className={clsx("whitespace-normal", className)}>
70+
{stripHtmlTags(content)}
71+
</div>
72+
);
73+
}
74+
5675
if (format === "markdown") {
5776
return (
5877
<div

tests/e2e_tests/incidents_alerts_tests/test_xss_protection.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ def test_legit_html_content(
110110
"table[data-testid='incidents-table'] tbody tr",
111111
has_text=legit_html_incident["user_generated_name"],
112112
).first
113-
html_content = incident_row.inner_html()
114-
assert "<h2>" in html_content, "H2 tag not found in HTML"
115-
assert "<code>" in html_content, "Code tag not found in HTML"
113+
# Incident list renders summaries as plain text (tags stripped) for
114+
# proper CSS line-clamp. Verify text content is preserved.
115+
text_content = incident_row.inner_text()
116+
assert "Test Failure" in text_content, "Summary text not found"
116117
assert (
117-
'<a href="https://google.com">' in html_content
118-
), "Link tag not found in HTML"
118+
"test_csb_upload_send_two_times_same_sequence_number" in text_content
119+
), "Code text not found in summary"
120+
assert "Google" in text_content, "Link text not found in summary"
119121
except Exception:
120122
save_failure_artifacts(browser, log_entries=[])
121123
raise

0 commit comments

Comments
 (0)