Repository navigation
feat(app): double-click a column's resize handle to fit it to its content - #3819
alex-fedotyev wants to merge 4 commits into
Conversation
…tent Double-clicking the resize handle on a search results column sets the column to the width of its widest rendered cell, header included, so it gets narrower or wider to match what it shows. A fitted column stops at 600px or half the visible table width, whichever is smaller. The last column already fills the space the others leave, so double-clicking it clears a dragged width and it fills the table again. The fitted width is saved and reset like a dragged one. Clearing the last column's width needs the column sizing handler to apply TanStack's updater to the stored sizes. It called the updater with no previous state and merged the result in, so a stored size could never be removed. The handler is now typed without `any`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: fbf843d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
E2E Test Results✅ All tests passed • 479 passed • 1 skipped • 1082s
Tests ran across 4 shards in parallel. |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
PR Review✅ No issues found. |
Deep Review✅ No critical issues found. This is a well-scoped, well-tested UI feature. The 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (3 of 11 completed at synthesis): performance, agent-native, learnings-researcher. Correctness, testing, maintainability, project-standards, adversarial, kieran-typescript, julik-frontend-races, and previous-comments were dispatched but had not returned when structured output was required; the findings above reflect the completed reviewers plus orchestrator-level analysis of the full diff. Testing gaps: No regression test asserts that the mousedown-initiated resize drag and the double-click fit do not interfere on the shared handle; the e2e suite exercises drag and double-click as separate gestures only. The component tests rely on a hand-built DOM fixture and mocked No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
- Read the visible table width when the handle is double-clicked, instead of the last width the resize observer reported. - Drop the empty-measurement guard. The header always has width, so the measurement is never 0 for the column being fitted. - Remove the measuring copies in a finally block, so a failed read cannot leave them in the table. - Note at both render sites what the measurement relies on, and why it measures the whole header row: the remove button and resize handle take room the label needs to show in full. - Test that a column whose header is wider than its values shows the whole label after a fit, the read-time width cap, and cleanup when a read throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review findings, addressed in 110a997:
|
Tables without a tableId keep column widths in TanStack's own state, which the last column's fill width and the table's min width don't read. A fit there narrowed a column without the last column growing to match, so the rows fell out of line with the header. Dragging in those tables already drifts the same way; this keeps the new gesture out of it. Also tests that a dragged width is still saved under the retyped column sizing handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Second review round, in fbf843d:
That's two rounds of automated review, so I'll leave anything further for a maintainer. |
pulpdrew
left a comment
There was a problem hiding this comment.
LGTM! Very convenient. It would be great if this also worked on dashboard search tiles in the future
Summary
Double-clicking a column's resize handle in the search results table now fits the column to its content, the same gesture spreadsheets and most data grids use. Until now the only way to size a column was to drag it.
It works in the tables that save their column widths: search results, and the Logs tab of a trace's side panel. Tables that only keep widths in memory (surrounding context, event patterns, the Kubernetes and dashboard panels) don't feed a resized column back into the last column's fill width, so a fit there would leave the rows out of line with the header. They keep drag resizing only, which already drifts the same way. Dashboard table tiles share the header component but size their columns from the tile width, so they keep today's behavior too.
How it measures. TanStack Table 8.7.9 has no auto-size, so
measureColumnContentWidth(new, inDBTable/columnFit.ts) clones the column's header cell and each rendered body cell out of view atwidth: max-contentand takes the widest. Measuring the DOM rather than the row data picks up how cells actually render (dates in the chosen time zone, log levels, search highlights, the content font size setting) without duplicating the cell renderers, and it works with wrap lines on. All the clones go in before the first read, so the table lays out once. Only mounted rows count (the visible ones plus the virtualizer's overscan), which is also how AG Grid's auto-size works. Cells of tables nested in an expanded row are skipped.Column sizing handler.
onColumnSizingChangecalled TanStack's updater with no previous state and merged the result into the stored sizes, so a stored width could be set but never removed:column.resetSize()would have thrownCannot destructure '_ref2' as it is undefined. It now applies the updater to the stored sizes, which is what lets the last column drop its width. Drags go through the same updater and behave as before, and the handler no longer needsany.Screenshots or video
Search on the demo server (Demo Logs, 1440 x 900). ServiceName dragged down to 70px so the service names are cut off, then its resize handle double-clicked. On
mainthe column stays at 70px. On this branch it fits its widest value at 117px.main)How to reproduce
Starting point: the Vercel preview on this PR, or
yarn app:dev:local→ onboarding → "Connect to Demo Server".On
main:On this branch:
Bodyin the middle of the SELECT (for exampleTimestamp, Body, ServiceName) and double-click its handle. It stops at half the table width.How to test on Vercel preview
Preview routes: /search
Steps:
data-testid="column-resize-handle") at the right edge of the "ServiceName" column header about 90px to the left, so the service names are cut off with "…".Test plan
yarn lint,yarn tsc --noEmitandyarn lint:stylesinpackages/app, andyarn knipcolumnFit.test.tscovers the widest cell with the header included, cell padding, skipping nested tables, cleanup when a read throws, and the cap. A new Fit column to content block inDBRowTable.test.tsxnarrows and saves a column, caps one at half the table (read when the handle is double-clicked), returns the last column to filling, and leaves tables that don't save their widths to drag resizing.saves the width a column is dragged tocovers drags under the retyped column sizing handler. Reverting any one part of the change (the double-click wiring, the measurement, the cap and minimum, the last-column rule, thetableIdcheck, or the sizing handler fix) fails at least one of them.tests/e2e/features/search/column-fit.spec.tswidens a squeezed column, narrows a widened one, shows the whole header label of a column whose header is wider than its values, returns the last column to filling, and keeps a fitted width after a reload. It passes locally in local mode, and every test fails with the double-click handler removed.References
[ui-states: allow] Fitting only changes a column's width. The table's empty, loading and error states are unchanged, and a column with no rendered cells is left as it is.