:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(lemon-ui): keep markdown table columns readable and scroll wide tables (#118566)
posthog[bot]4a92d4559a00
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 946c2b333959..afdaa935b3be 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5392,6 +5392,10 @@ snapshots:hash: v1.k794b7964.7c71ed6873f129ca5bcd6bfc799c99150b622d71e8c1704f1c43df4fbbb76549.2Ho5GXNsKrQZBkH-BDJmoOPANdExoh7swpQKiSPAm54lemon-ui-lemon-markdown--mermaid-diagrams--light:hash: v1.k794b7964.5f1d7a14bc8d292185ea2e8757aacea1b1592621474a40a0f2800689bdc967b4.nX6LZuh3nECdwHBEofLKwHYMbt5-wreAHYJTpyarEzA+ lemon-ui-lemon-markdown--mixed-width-table--dark:+ hash: v1.k794b7964.d9ee2b2f8b60c33589726536d9aa3d686ae17aeffd19ef0d02ab55d199577bfc.0LmTzNxmZkyAZ806BqQ-bxhOwkfztpZQCKo6ag9oMx4+ lemon-ui-lemon-markdown--mixed-width-table--light:+ hash: v1.k794b7964.a6f91589aae73c98f4d629b51c371af7cc01ed89207a1dd6d482393802a61235.2eqNRUHEh_ZBja6QNjBbNrj8DzMHI8R-8Pmx-x84goQlemon-ui-lemon-markdown--strikethrough--dark:hash: v1.k794b7964.6f43730a305fab3c583f6afcb4a0ff8777a74ca784de794c252ea9692f6793c2.IeFouIlnojE5FLab-REEZEF6yehG0OQlawod7eMKOwYlemon-ui-lemon-markdown--strikethrough--light:diff --git a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.scss b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.scssindex 6141be815f7e..dc3ae00ef8aa 100644--- a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.scss+++ b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.scss@@ -84,9 +84,14 @@}// Table styling - minimal approach- table {+ // A <table> ignores `overflow`, so a wrapper scrolls a wide table instead of squeezing its columns.+ .LemonMarkdown__table-wrapper {+ max-width: 100%;margin: 1em 0;- overflow: auto;+ overflow-x: auto;+ }++ table {border-spacing: 0;border-collapse: separate;border: 1px solid var(--border);@@ -95,9 +100,14 @@th,td {+ // Stops one long prose cell from taking all the width from the short columns.+ max-width: 40rem;padding: 0.375rem 0.75rem;color: var(--default);text-align: left;++ // `anywhere` lets a column shrink to one character. `break-word` keeps the longest word as the minimum.+ overflow-wrap: break-word;vertical-align: top;border-right: 1px solid var(--border);border-bottom: 1px solid var(--border);diff --git a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.stories.tsx b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.stories.tsxindex 870ac890ac77..86dd2adf5a68 100644--- a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.stories.tsx+++ b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.stories.tsx@@ -77,6 +77,26 @@ Here's a breakdown of our top traffic sources:},}+export const MixedWidthTable: Story = {+ render: (args) => (+ <div className="flex flex-col gap-4">+ {['w-[520px]', 'w-[1200px]'].map((widthClassName) => (+ <div key={widthClassName} className={`border p-2 ${widthClassName}`}>+ <LemonMarkdownComponent {...args} />+ </div>+ ))}+ </div>+ ),+ args: {+ children: `A long prose cell does not squeeze the short columns. A table that does not fit scrolls sideways.++| View | Grain | Materialized | Notes |+| --- | --- | --- | --- |+| some_long_view_name_here | 1 / run (task_run_id) | yes (24h -> 1h) | One row per task run, joined to its outputs. The view reads from \`example_task_runs_with_outputs\` and \`example_task_run_artifacts\`, and keeps the latest status for each run. Use it to count runs per day or to find runs that stopped before they wrote an output. |+| daily_rollup | 1 / day | no | Short note. |`,+ },+}+export const GitHubFlavoredMarkdown: Story = {args: {children: `# GitHub-flavored Markdown featuresdiff --git a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.tsx b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.tsxindex ca7269934ac7..443239d642d6 100644--- a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.tsx+++ b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdown.tsx@@ -246,6 +246,11 @@ const LemonMarkdownRenderer = memo(function LemonMarkdownRenderer({},}: {}),+ table: ({ node, ...props }: any): JSX.Element => (+ <div className="LemonMarkdown__table-wrapper">+ <table {...props} />+ </div>+ ),span: ({ className, ...props }: any): JSX.Element => {if (className === 'ph-mention') {return <RichContentMention id={Number(props['data-mention-id'])} />