You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow for letter spacing when sizing result grid columns by their data. #10921 - #10929
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.
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.
Closespgadmin-org#10921
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.
pgadmin-org/pgadmin4#10854: Adds a results-grid font size multiplier that also affects canvas measurements for column sizing.
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: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
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
[#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
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bodya letter spacing of0.01071em(0.15px at the body's 14px), which the results grid inherits, but canvasmeasureTextignores 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.Roboto, and picks the widest value by measured width instead of by character count.Test plan
example_string_that_gets_clippedrenders 4.1px wider than canvasmeasureTextreports; the corrected measurement covers it.QueryToolDataGridColumnWidth.spec.js; all 24 sqleditor Jest suites pass, eslint clean.SELECT 'example_string_that_gets_clipped';shows the full value.Closes #10921
Summary by CodeRabbit