Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertically align cell contents in DataTable #3843

Merged
merged 6 commits into from
Oct 31, 2023
Merged

Conversation

thyeggman
Copy link
Contributor

Changelog

This PR vertically aligns cell content for the DataTable component. When a row has actions, the typical pattern is to use an IconButton. However, the button is taller than the row when the row contents are text. Currently, by default, cell contents are top-aligned, so this creates a disparity between the top and bottom margins for cell content. This is best demonstrated by this storybook:

DataTable row with action highlighting vertical alignment mismatch

New

Added styles to TableCell and TableHeader

Changed

NA

Removed

NA

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan

Testing & Reviewing

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@thyeggman thyeggman requested review from a team and joshblack October 19, 2023 21:57
@changeset-bot
Copy link

changeset-bot bot commented Oct 19, 2023

🦋 Changeset detected

Latest commit: 1fae2c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 103.55 KB (0%)
dist/browser.umd.js 104.13 KB (0%)

@thyeggman thyeggman temporarily deployed to github-pages October 19, 2023 22:05 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3843 October 19, 2023 22:06 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3843 October 19, 2023 23:37 Inactive
@thyeggman thyeggman temporarily deployed to github-pages October 19, 2023 23:38 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3843 October 19, 2023 23:38 Inactive
@thyeggman
Copy link
Contributor Author

Here's a screenshot from the storybook showing the new alignment:

data table with row contents vertically aligned to the middle

Copy link
Collaborator

@pksjce pksjce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like this change. The table cell items look a lot better. I ran the storybooks and compared them with the original and couldn't really find any regressions so far. I will approve but please don't merge till @joshblack or @mperrotti (original component authors) approve

Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Will wait to see what @mperrotti says before merging 👀

Copy link
Contributor

@mperrotti mperrotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to merging this with the assumption that most table cells will not wrap to multiple lines.

@@ -66,7 +66,10 @@ const StyledTable = styled.table<React.ComponentPropsWithoutRef<'table'>>`
.TableHeader,
.TableCell {
text-align: start;
display: flex;
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little worried about how this might affect the readability of rows where some cells have 1 line of text, and other cells wrap to 2+ lines.

Compare these two tables:
vertically centered rows

flush top rows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point. I'm not sure if the best solution is something that involves proper padding if there's a row action available, or increasing the base height of a row when there is no action. I don't think anyone but us is using DataTable at the moment, and our current plan is to truncate row content when it overflows a cell.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late on this but I think align-items: baseline would solve for that specific issue, though not sure if it would introduce problems with other elements like IconButtons or Labels.

@joshblack joshblack temporarily deployed to github-pages October 31, 2023 17:56 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3843 October 31, 2023 17:57 Inactive
@joshblack joshblack added this pull request to the merge queue Oct 31, 2023
Merged via the queue into main with commit 4ea8bcf Oct 31, 2023
29 checks passed
@joshblack joshblack deleted the thyeggman/align-table-cell branch October 31, 2023 18:09
@primer primer bot mentioned this pull request Oct 31, 2023
@mperrotti mperrotti mentioned this pull request Dec 6, 2023
12 tasks
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.

5 participants