Repository navigation
feat(data-grid): double-click a column border to fit its width - #1339
Conversation
| // Double-clicking a resize handle fits that column to its header and the | ||
| // loaded rows (#1295). Cells are measured on a canvas with the result font, | ||
| // so the table never reflows; the header is measured at its natural width. | ||
| // Double-clicking a resize handle fits that column to its header and the |
There was a problem hiding this comment.
WARNING: Duplicated comment block
The second commit added a second copy of the "Double-clicking a resize handle..." comment directly under the first one (lines 1636-1638). Remove one of them (the older one also states the canvas uses "the result font", which is no longer accurate since the font is now read from a rendered cell).
| `tbody td[data-col-index="${colIndex}"]`, | ||
| ) ?? null; | ||
| const cellStyle = sampleCell ? getComputedStyle(sampleCell) : null; | ||
| ctx.font = cellStyle?.fontSize |
There was a problem hiding this comment.
WARNING: Fit width is measured against the wrong text metrics when no rows are rendered/virtualized in the column
sampleCell is the first rendered tbody td of the column. If the grid is empty or only padding rows are rendered, cellStyle is null and the fallback uses a hard-coded 14px plus FIT_COLUMN_PADDING = 33, ignoring the font-size setting the comment on line 1650 says must be followed. Also, ${cellStyle.fontWeight} ${cellStyle.fontSize} ${cellStyle.fontFamily} is measured with the body cell font while the header text (text-xs font-semibold tracking-wider) is measured through DOM, so that part is fine; but cell values rendered with a different font (e.g. monospace for JSON/numbers via a nested element) would be mis-measured. Consider measuring from the inner content element of the cell rather than the td.
| /> | ||
| </tr> | ||
| )} | ||
|
|
There was a problem hiding this comment.
SUGGESTION: Unrelated whitespace change
This added blank line is unrelated to the feature; drop it to keep the diff focused.
| import {SetCellsValueModal} from '@/components/modals/SetCellsValueModal'; | ||
| import {KeybindingsContext} from '@/contexts/KeybindingsContext'; | ||
|
|
||
| /** Horizontal padding of a grid cell (px-4 on both sides) plus its 1px border. */ |
There was a problem hiding this comment.
SUGGESTION: Missing blank lines around the new constant
The blank line that previously separated the imports from DataGridCommandTarget was removed, so the new doc comment/constant is glued to the import block and to the following export interface. Restore blank lines before and after FIT_COLUMN_PADDING.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (1 file in incremental diff)
Fix these issues in Kilo Cloud Previous Review Summary (commit f47bdf9)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit f47bdf9)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (16 files)
Reviewed by claude-sonnet-5.5 · Input: 250 · Output: 1.8K · Cached: 171.1K Review guidance: REVIEW.md from base branch |
debba
left a comment
There was a problem hiding this comment.
Thanks for fitting columns using the rendered font and padding, and adding a way to reset manual widths.
Since this is your first PR here, we would be happy to have you join us on Discord if you would like to get involved: https://discord.com/invite/K2hmhfHRSt
I have not found an obvious blocker in the diff. I will run end-to-end checks in the real app for further verification, then proceed with the merge if those checks pass.
|
I tested this in the real macOS app with a SQLite table containing NULLs, empty strings, multiline text and longer values. Double-click fitting changes only the chosen column, reset restores automatic widths, and fitting a frozen first column and resizing it with the keyboard both work. No console errors appeared. Typecheck, formatting, theme checks and ESLint excluding local worktrees and generated bundles pass; full suites show only the failures reproduced on main. Ready to merge. |
Closes #1295
Double-clicking a column resize handle now fits that column to its header and the loaded rows, within the existing minimum and maximum column widths. Only that column changes. The header context menu also has a new "Reset column widths" entry that drops the manual widths and goes back to the automatic layout.
Changes:
Keyboard resizing on the focused handle works as before.