Skip to content

Allow for letter spacing when sizing result grid columns by their data. #10921 - #10929

Open
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10921-column-data-width
Open

dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10921-column-data-width

Conversation

@dpage

@dpage dpage commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The theme gives body a letter spacing of 0.01071em (0.15px at the body's 14px), which the results grid inherits, but canvas measureText ignores it. Columns sized by Column data therefore came out short by about 0.15px per character (around 5px for the value in the issue), and the widest value lost its last characters to an ellipsis.
  • The width calculation now adds the computed letter spacing per character, rounds up to a whole pixel, measures with the page's font family rather than a hard-coded Roboto, and picks the widest value by measured width instead of by character count.

Test plan

  • In headless Chrome with the bundled Roboto and the body's letter spacing, example_string_that_gets_clipped renders 4.1px wider than canvas measureText reports; the corrected measurement covers it.
  • New Jest spec QueryToolDataGridColumnWidth.spec.js; all 24 sqleditor Jest suites pass, eslint clean.
  • Check in the Query Tool that SELECT 'example_string_that_gets_clipped'; shows the full value.

Closes #10921

Summary by CodeRabbit

  • Bug Fixes
    • Improved SQL editor grid column sizing so columns better fit the text displayed in cells and headers, accounting for font proportions, letter spacing, and Unicode characters.
    • Column widths continue to respect maximum-width limits and saved sizing preferences, helping keep the grid layout consistent.

pgadmin-org#10921

The theme gives the page body a letter spacing of 0.01071em, which the
results grid inherits, but canvas measureText does not include it, so
columns sized by their data came out a few pixels too narrow (about 5px
for a 32-character value) and the widest value lost its last characters
to an ellipsis. Add the spacing for each character, round the width up
to a whole pixel, measure with the page's font family rather than a
hard-coded Roboto, and pick the widest value by its measured width
rather than by its number of characters.

Closes pgadmin-org#10921
@dpage dpage self-assigned this Dec 2, 2026
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Column sizing in the SQL Editor Data Output grid now uses measured text widths based on the page font and letter spacing. Tests cover text measurement and column-width rules.

Changes

SQL Editor grid column sizing

Layer / File(s) Summary
Page-font text measurement
web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/index.jsx
Column initialization uses the page body font family and letter spacing. The text measurer adds finite letter spacing per Unicode code point and rounds widths up.
Measured column-width rules
web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/index.jsx, web/regression/javascript/sqleditor/QueryToolDataGridColumnWidth.spec.js
Column sizing compares measured truncated values, measures header text, and sums measured row widths for numeric sizing. Tests cover Unicode spacing, width limits, widest-value sizing, and by_name sizing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: pravesh-sharma

Merge Risk: Minimal · up to d542d

This change makes Query Tool columns sized by column data account for the page's letter spacing, so the last characters are no longer clipped. The scope is a UI sizing tweak with tests, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: column sizing by Column data now accounts for letter spacing. The raw summary confirms the change adds letter spacing to canvas measurement in getColumnWidth, and the …
Linked Issues check Passed [#10921] requires that initial Column data sizing in the Query Tool Data Output grid include enough width for the full string. The diff in web/pgadmin/tools/sqleditor/static/js/components/QueryToolDat…
Out of Scope Changes check Passed All changes in the whole-PR diff (merge base 364b4ae to head d542df2) relate to Column data width calculation in the Query Tool grid. The changes are: the text measurement and letter-spacing logic i…
Full details: Title check

Explanation

The title names the main change: column sizing by Column data now accounts for letter spacing. The raw summary confirms the change adds letter spacing to canvas measurement in getColumnWidth, and the objectives say the fix targets clipped result columns sized by Column data. The title is specific and matches the changeset. The issue number reference is a minor addition and does not affect the result.

Full details: Linked Issues check

Explanation

[#10921] requires that initial Column data sizing in the Query Tool Data Output grid include enough width for the full string. The diff in web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/index.jsx addresses the root cause named in the issue. The new getTextMeasurer adds the computed body letter spacing (parseFloat of getComputedStyle(document.body).letterSpacing) for each character, then rounds up with Math.ceil. The canvas font now uses the page font family instead of hard-coded Roboto. getColumnWidth now takes the maximum measured width over the truncated row values, not the longest string by length. This applies the same measurement to the header and to numeric columnWidthBy sizing, and the existing maximum-width cap and saved-width override are kept. The PR adds web/regression/javascript/sqleditor/QueryToolDataGridColumnWidth.spec.js, which covers letter-spacing measurement, widest-value selection, and the width limits. I did not run the Jest suite. The manual check for SELECT 'example_string_that_gets_clipped'; is unchecked in the PR. That check is a manual step, not a coding requirement. The fix matches the reported mechanism, so the coding requirements are met.

Full details: Out of Scope Changes check

Explanation

All changes in the whole-PR diff (merge base 364b4ae to head d542df2) relate to Column data width calculation in the Query Tool grid. The changes are: the text measurement and letter-spacing logic in QueryToolDataGrid/index.jsx, the row-number width now using the same measurer, and the new Jest spec for that logic. The getColumnWidth and getTextMeasurer exports exist only to support tests of this logic. No unrelated functional change appears in the reviewed diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 364b4ae and d542df2.

Files selected for processing: 2

  • web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/index.jsx
  • web/regression/javascript/sqleditor/QueryToolDataGridColumnWidth.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wide columns in Data Output are always just a few pixels too small

1 participant