Skip to content

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

Open
LinKCoding wants to merge 16 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 16 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 80a2fdf


☁️ Nx Cloud last updated this comment at 2026-03-17 14:07:09 UTC

@codecov
Copy link

codecov bot commented Mar 3, 2026

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

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

@LinKCoding LinKCoding requested a review from dreamwasp March 16, 2026 15:41
Copy link
Contributor

@dreamwasp dreamwasp left a comment

Choose a reason for hiding this comment

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

lgtm! if you have time could you remove the red BG on this List example? ik it is unrelated and literally probably something i did

Image i

@github-actions
Copy link
Contributor

@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]

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