Skip to content

: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.

fix(sql): restore dashboard SQL table scrolling (#57770)

Marius Andra82993d3fdd29
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx
index a610a8e2020d..cd202fc6c5ec 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx
@@ -248,6 +248,7 @@ export const Table = (props: TableProps): JSX.Element => {
footer={tabularData.length > 0 ? <LoadNext query={props.query} /> : null}
rowClassName="DataVizRow"
embedded={props.embedded}
+ allowContentScroll={!!props.embedded}
/>
)
}
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx
new file mode 100644
index 000000000000..5e6b99373ba2
--- /dev/null
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx
@@ -0,0 +1,84 @@
+import { cleanup, render, waitFor } from '@testing-library/react'
+
+import { DataVisualizationNode, HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+import { ChartDisplayType } from '~/types'
+
+import { DataTableVisualization } from './DataVisualization'
+
+type LemonTableMockProps = {
+ embedded?: boolean
+ allowContentScroll?: boolean
+}
+
+let mockLatestLemonTableProps: LemonTableMockProps | null = null
+const mockLemonTable = jest.fn((props: LemonTableMockProps): null => {
+ mockLatestLemonTableProps = props
+ return null
+})
+
+jest.mock('@posthog/lemon-ui', () => ({
+ ...jest.requireActual('@posthog/lemon-ui'),
+ LemonTable: (props: Record<string, unknown>): null => {
+ mockLemonTable(props)
+ return null
+ },
+}))
+
+describe('DataTableVisualization', () => {
+ const query: DataVisualizationNode = {
+ kind: NodeKind.DataVisualizationNode,
+ source: {
+ kind: NodeKind.HogQLQuery,
+ query: 'select number from numbers(2)',
+ },
+ display: ChartDisplayType.ActionsTable,
+ }
+
+ const cachedResults: HogQLQueryResponse<number[][]> = {
+ results: [[1], [2]],
+ columns: ['number'],
+ types: [['number', 'Int64']],
+ }
+
+ beforeEach(() => {
+ initKeaTests()
+ mockLatestLemonTableProps = null
+ mockLemonTable.mockClear()
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ test.each([
+ { embedded: true, expectedAllowContentScroll: true },
+ { embedded: false, expectedAllowContentScroll: false },
+ ])(
+ 'sets table scroll mode to $expectedAllowContentScroll when embedded is $embedded',
+ async ({ embedded, expectedAllowContentScroll }) => {
+ render(
+ <DataTableVisualization
+ uniqueKey={`data-visualization-scroll-${embedded}`}
+ query={query}
+ setQuery={jest.fn()}
+ cachedResults={cachedResults}
+ readOnly
+ embedded={embedded}
+ />
+ )
+
+ await waitFor(() => {
+ if (!mockLatestLemonTableProps) {
+ throw new Error('Expected LemonTable to render')
+ }
+ })
+
+ if (!mockLatestLemonTableProps) {
+ throw new Error('Expected LemonTable props to be recorded')
+ }
+ expect(mockLatestLemonTableProps.embedded).toBe(embedded)
+ expect(mockLatestLemonTableProps.allowContentScroll).toBe(expectedAllowContentScroll)
+ }
+ )
+})
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index 15216feb610d..840072889c10 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -226,6 +226,7 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
query={query}
context={props.context}
cachedResults={props.cachedResults as HogQLQueryResponse | undefined}
+ embedded={props.embedded}
/>
)
} else if (