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

progress table layout cleanup #39091

Merged
merged 5 commits into from
Feb 17, 2021
Merged

progress table layout cleanup #39091

merged 5 commits into from
Feb 17, 2021

Conversation

cforkish
Copy link
Contributor

@cforkish cforkish commented Feb 17, 2021

we discovered a few non-blocking bugs in our table layout during final testing, which this PR resolves.

  1. the detail view second header row was 1px shorter in the content view than in the student list, causing the whole table to be misaligned by 1px.
  2. we had not accounted for level icon layout in multi-level lessons that include an unplugged level.
  3. unplugged bubble widths were being calculated incorrectly in chrome, causing those bubbles to overflow their columns (more on this below).
  4. we had inadvertently made the tables taller by setting their body heights to the previous height of the whole table

before

Screen Shot 2021-02-17 at 10 30 02 AM

after

Screen Shot 2021-02-17 at 10 45 15 AM

unplugged widths

we were using a hacky method to calculate the width of a localized unplugged bubble by rendering it in the dom, measuring it, then removing it. however, i discovered right after we shipped that chrome was producing the wrong value in this calculation. after some investigation it turned out that our font wasn't fully loaded by the time the calculation was run, resulting in a smaller pixel width.

after trying a few different ways to solve this width calculation problem, i decided to revisit the underlying need for explicit widths in the first place. in short, while there were several motivating factors, the only actual need was for calculating the width of the table to conditionally render a gutter at the bottom of the student list when the content view is displaying a scrollbar. it had never occurred to me before that a much simpler (though slightly less visually appealing) solution was to just have both parts of the table always show a gutter to avoid the need to know if the content view is showing a scrollbar.

making this change allowed for a lot of good code simplification. however, due to how reactabular handles sticky headers and body virtualization, our table headers are unable to automatically size themselves based on cell content in the body, which means the headers either need to know the exact width of their body columns, or they need to render something of the same size. the way i handled this before running into the scrollbar-gutters-need-table-width issue was to simply render an invisible dummy detail cell in the header to define its size. this is obviously also hacky, but imo much less so than the previous dom measurement solution. and since the unplugged bubble is the only bubble with a dynamic size, i'm only using the hack for those icons.

tl;dr -- our detail view content table is now sizing its columns based on content size rather than explicit width. in the headers, it gets that size from the ProgressTableLevelIcon. in the body, it gets the same size from the ProgressTableDetailCell. summary view content table is still using explicit width constraints to avoid some off-by-one rounding errors between header and body cells that i was seeing during development.

@@ -166,7 +168,8 @@ export default class ProgressTableContentView extends React.Component {
rowKey={'id'}
onScroll={this.props.onScroll}
style={{
overflow: 'auto',
overflowX: 'scroll',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i tried just setting this to scroll for both to avoid the need for any gutter calculations, but deemed the visual benefit of only showing it conditionally to be well worth the cost.

Copy link
Contributor

Choose a reason for hiding this comment

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

In case this was confusing to anyone else, this comment applies to L171-172 and explains why overflowY is not set to 'scroll'

Copy link
Contributor

@jamescodeorg jamescodeorg left a comment

Choose a reason for hiding this comment

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

Nice simplifications!

@@ -103,9 +103,11 @@ export default class ProgressTableContentView extends React.Component {

columnWidthStyle(index) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a comment somewhere around here describing when we expect columnWidths to be specified and when not and the overall behavior associated with each case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -166,7 +168,8 @@ export default class ProgressTableContentView extends React.Component {
rowKey={'id'}
onScroll={this.props.onScroll}
style={{
overflow: 'auto',
overflowX: 'scroll',
Copy link
Contributor

Choose a reason for hiding this comment

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

In case this was confusing to anyone else, this comment applies to L171-172 and explains why overflowY is not set to 'scroll'

// The width of our unplugged bubble depends on the localization of the text,
// so to allow that to be determined at render time, we don't set an explicit
// width for unplugged bubbles and instead render an invisible one behind the
// icon to determine its width.
Copy link
Contributor

Choose a reason for hiding this comment

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

I could use some clarification here, are we rendering the hidden progress bubble here because the header is determining the width of the column?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

more specifically, we're adding the hidden progress bubble here so that the intrinsic content width of the unplugged icon will match that of the bubble, regardless of context.

hopefully the comment i just added to ProgressTableContentView.columnWidthStyle will clarify why this is necessary -- the content width of the ProgressTableLevelBubbles determine the width of the body columns, but for our header columns to have the same width without it being provided explicitly, they need to have the same content width as the body columns. so in our case, this is determining the width of the header columns, but specifically not of the body columns (ProgressTableLessonNumber sizes itself based on its container, so does not contribute to the determination of the header column width). lmk if that's still unclear!

Copy link
Contributor

@maureensturgeon maureensturgeon left a comment

Choose a reason for hiding this comment

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

🥇 so much cleanup!!! Looks great

@cforkish cforkish merged commit ed5b97c into staging Feb 17, 2021
@cforkish cforkish deleted the cforkish/table-layout-cleanup branch February 17, 2021 23:38
@cforkish cforkish added the student progress PRs related to student progress label Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
student progress PRs related to student progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants