Skip to content

fix(DataList): Padding on first column and alignment for headers#3277

Open
LinKCoding wants to merge 12 commits intomainfrom
kl-gmt-1544-datalist-th-td-padding
Open

fix(DataList): Padding on first column and alignment for headers#3277
LinKCoding wants to merge 12 commits intomainfrom
kl-gmt-1544-datalist-th-td-padding

Conversation

@LinKCoding
Copy link
Contributor

@LinKCoding LinKCoding commented Mar 3, 2026

Overview

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-1544 GMT-1573
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Don't make me tap the sign.

  1. Go to DataList
  2. Look like the "Non-selectable rows" section and verify that the "Rank" header and the column's text are all aligned correctly (i.e. have the same padding) — optionally check against prod where there is extra 8 padding on the column's text
  3. Inspect the header and see that only the first element gets the pl: 8 and the last element gets pr:8 (this can be done on one or many DataList)
  4. Scan through the other examples and see that the columns all align properly — optionally check against prod examples too
  5. Shrink the screen size to check against mobile sizes and check alignments
  6. Check DataTable too and see that they all look the same as prod
  7. Repeat for List
  8. ...
  9. Finish and do a celebratory dance

PR Links and Envs

Repository PR Link
Mono Mono PR

@nx-cloud
Copy link

nx-cloud bot commented Mar 3, 2026

View your CI Pipeline Execution ↗ for commit 566a00e


☁️ Nx Cloud last updated this comment at 2026-03-10 15:23:55 UTC

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.03%. Comparing base (e77a712) to head (566a00e).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3277      +/-   ##
==========================================
- Coverage   89.87%   89.03%   -0.84%     
==========================================
  Files         361      236     -125     
  Lines        5144     4324     -820     
  Branches     1645     1477     -168     
==========================================
- Hits         4623     3850     -773     
+ Misses        513      466      -47     
  Partials        8        8              
Flag Coverage Δ
main ?
pull-request 89.03% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

: sortDirection === 'asc'
? 'ascending'
: 'descending';
{selectable && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the fragment b.c. it was interfering with the addition of data-first-col for the first element in the TableHeader
Also doesn't seem necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not using data-*-col approach anymore, so re-adding is fine, but it's also not necessary from what I can tell

@LinKCoding LinKCoding changed the title starting point fix(DataList): Padding on first column and alignment for headers Mar 4, 2026
@LinKCoding LinKCoding marked this pull request as ready for review March 6, 2026 20:53
@LinKCoding LinKCoding requested a review from a team as a code owner March 6, 2026 20:53
@LinKCoding LinKCoding requested review from jakemhiller and sh0ji March 6, 2026 20:53
Comment on lines +1 to +4
import { Children, cloneElement, isValidElement, ReactNode } from 'react';

/**
* Marks the first and last columns with `data-first-col` / `data-last-col`
Copy link
Contributor

Choose a reason for hiding this comment

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

i really dislike cloning children, especially in a component like a DataList where we're already looping though all the columns to render them and there could be alot of them. maybe we you can move this logic into checking the idx of the React.Map in TableHeaderRow?

Copy link
Contributor Author

@LinKCoding LinKCoding Mar 10, 2026

Choose a reason for hiding this comment

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

FWIW, I did try this approach and it worked well for TableHeaderRow!
But when I went to see how we could use it for List, I ran into an issue again where the children are pretty configurable - i.e. I couldn't just add to the children's attribute without some type of new iteration.

And then after trying another approach with setting context and passing on the idx, the robot confirmed my suspicion that it's just as expensive as cloning.

So instead, I went back to the drawing board and realized that if we can't add padding to the children, maybe we can do that for the parent (row) instead. Since we only want either the first td or th — which seems like it'd translate to just the px of the row itself.

Looks like this works, and I've cleaned up some code that tries to be selective about what child gets padding. But yea, would compare against DataList, DataTable, and List.

@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/gamut@68.0.6-alpha.8001ec.0
@codecademy/gamut-kit@0.6.585-alpha.8001ec.0

@github-actions
Copy link
Contributor

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.

3 participants