table: Allow custom DataTable row height - #2364
Merged
Merged
Conversation
Member
|
Thank you, I’ve added a pixel example in the story. |
madcodelife
enabled auto-merge (squash)
May 13, 2026 03:40
Contributor
Author
Thank! |
AzureZee
pushed a commit
to AzureZee/gpui-component
that referenced
this pull request
May 16, 2026
Closes longbridge#2352 ## Description This pull request fixes `DataTable::with_size(px(...))` so custom pixel sizes are used as the table row height. Previously, `Size::table_row_height()` only mapped the preset sizes (`XSmall`, `Small`, `Medium`, and `Large`) to row heights. A custom `Size::Size(px)` value fell back to the default medium row height (`32px`), which meant calls such as `DataTable::new(&state).with_size(px(48.))` did not change the DataTable header or body row height. The fix makes `Size::Size(px)` return its own pixel value from `table_row_height()`. This keeps DataTable's existing single uniform row-height model intact, so header rows, body rows, loading skeleton rows, scrollbar offsets, page navigation, and stripe filler calculations continue to use the same height source. This PR also adds a focused regression test for the preset and custom table row height mappings, and updates the English and Chinese DataTable documentation to describe custom row height usage. ## Screenshot | Before | After | | ------ | ----- | | `DataTable::new(&state).with_size(px(48.))` still used the default `32px` row height. | `DataTable::new(&state).with_size(px(48.))` uses a uniform `48px` header and body row height. | ## How to Test Run the focused regression test: ```bash cargo test -p gpui-component test_table_row_height ``` Run the full `gpui-component` unit test suite: ```bash cargo test -p gpui-component ``` I also checked the patch for whitespace errors: ```bash git diff --check ``` ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. - [ ] Passed `cargo run` for story tests related to the changes. Not run; this is a non-visual sizing helper fix covered by unit tests. - [x] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific). Not platform-specific; no platform-specific performance impact is expected. --------- Co-authored-by: Floyd Wang <gassnake999@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2352
Description
This pull request fixes
DataTable::with_size(px(...))so custom pixel sizes are used as the table row height.Previously,
Size::table_row_height()only mapped the preset sizes (XSmall,Small,Medium, andLarge) to row heights. A customSize::Size(px)value fell back to the default medium row height (32px), which meant calls such asDataTable::new(&state).with_size(px(48.))did not change the DataTable header or body row height.The fix makes
Size::Size(px)return its own pixel value fromtable_row_height(). This keeps DataTable's existing single uniform row-height model intact, so header rows, body rows, loading skeleton rows, scrollbar offsets, page navigation, and stripe filler calculations continue to use the same height source.This PR also adds a focused regression test for the preset and custom table row height mappings, and updates the English and Chinese DataTable documentation to describe custom row height usage.
Screenshot
DataTable::new(&state).with_size(px(48.))still used the default32pxrow height.DataTable::new(&state).with_size(px(48.))uses a uniform48pxheader and body row height.How to Test
Run the focused regression test:
cargo test -p gpui-component test_table_row_heightRun the full
gpui-componentunit test suite:cargo test -p gpui-componentI also checked the patch for whitespace errors:
Checklist
cargo runfor story tests related to the changes. Not run; this is a non-visual sizing helper fix covered by unit tests.