Skip to content

table: Allow custom DataTable row height - #2364

Merged
madcodelife merged 2 commits into
longbridge:mainfrom
lurenjia534:main
May 13, 2026
Merged

table: Allow custom DataTable row height#2364
madcodelife merged 2 commits into
longbridge:mainfrom
lurenjia534:main

Conversation

@lurenjia534

Copy link
Copy Markdown
Contributor

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, 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:

cargo test -p gpui-component test_table_row_height

Run the full gpui-component unit test suite:

cargo test -p gpui-component

I also checked the patch for whitespace errors:

git diff --check

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • 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.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific). Not platform-specific; no platform-specific performance impact is expected.

@madcodelife

Copy link
Copy Markdown
Member

Thank you, I’ve added a pixel example in the story.

@madcodelife
madcodelife enabled auto-merge (squash) May 13, 2026 03:40
@madcodelife
madcodelife merged commit d40de3e into longbridge:main May 13, 2026
4 checks passed
@lurenjia534

lurenjia534 commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, I’ve added a pixel example in the story.

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>
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.

DataTable: Cannot override table-head table-row height with render_header / render_tr

2 participants