Skip to content

report: prevent opportunity savings from wrapping #14619

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

Merged
merged 5 commits into from
Jan 26, 2023
Merged

report: prevent opportunity savings from wrapping #14619

merged 5 commits into from
Jan 26, 2023

Conversation

alexnj
Copy link
Member

@alexnj alexnj commented Dec 16, 2022

(EDIT: these images do not reflect the changes made in the PR)

It will maintain right alignment of sparklines as before, until the savings get too big, then it will prioritize not wrapping.

Before:
image

After:
image
image

@alexnj alexnj requested a review from a team as a code owner December 16, 2022 02:33
@alexnj alexnj requested review from connorjclark and removed request for a team December 16, 2022 02:33
@brendankenny
Copy link
Contributor

These wrapping bugs never die :) what happened since #14329?

@alexnj
Copy link
Member Author

alexnj commented Dec 16, 2022

I guess the savings grew over time ;)

@@ -874,6 +874,7 @@
.lh-audit--load-opportunity .lh-audit__display-text {
text-align: right;
flex: 0 0 calc(4 * var(--report-font-size));
white-space: nowrap;
Copy link
Member

@adamraine adamraine Dec 16, 2022

Choose a reason for hiding this comment

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

The solution in #14329 was to increase the width instead of doing white-space: nowrap so the columns would stay aligned.

Could we just increase it again?

Copy link
Member Author

@alexnj alexnj Dec 16, 2022

Choose a reason for hiding this comment

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

The issue with that is, for those reports where savings are less digits (which I'm hoping is a good majority?), we'd leave a larger white space between sparkline and the savings. We applied 4 as the multiplier during that time on that basis, since it looked like a sweet spot. Yet a larger value still won't guarantee no breakage for a site that's worse-performing, or has an even higher savings in report.

I think an ideal case design would be a full refactor of opportunity tables with display: grid, where we could potentially minimize a column width to the maximum across all rows' content within that column. Seems theoretically possible, but I haven't tried yet.

This fix keeps the earlier sweet spot that works for majority, and decides to throw sparklines off a bit for offenders, but does guarantees a no-wrapping outcome for any value.

... or, should we refactor with display: grid? Overkill? wdyt?

PS: I see that you had commented on an earlier issue about white-space: nowrap.

Copy link
Member

@adamraine adamraine Dec 16, 2022

Choose a reason for hiding this comment

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

... or, should we refactor with display: flex? Overkill? wdyt?

I think the grid approach is tempting but probably not worth the work. I think that having some risk of word wrap is better than having some risk of the sparklines not lining up.

Copy link
Member Author

Choose a reason for hiding this comment

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

just to make sure I'm reading you right — you'd prefer the wrapped column with extra height, than sparklines misaligned? I.e., screenshot 1 is better than screenshot 2?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, otherwise the sparklines could appear longer than they actually are. I still think we should try expanding the number's area though.

@connorjclark
Copy link
Collaborator

connorjclark commented Jan 26, 2023

These wrapping bugs never die :) what happened since #14329?

I confirmed this exact problem happens even for 25b030426 (that PR).

The root cause here is:

.lh-audit--load-opportunity .lh-audit__display-text {
    text-align: right;
    flex: 0 0 calc(4 * var(--report-font-size));
}

We come up with a fixed value for the flex-basis of this item, such that all these independent flex containers will line up on the end of the sparkline. 4 * var(--report-font-size) just happens to not be enough space for the xx.xx sec text we are rendering. I saw the wrapping fixed by simply bumping that multiplier to 5. I'd be more interested in a fix that utilized a grid layout for these audit containers - but I'm not sure if that's possible given how these things are details that can be expanded (maybe some clever usage of display: contents would help here?)

@@ -874,6 +874,7 @@
.lh-audit--load-opportunity .lh-audit__display-text {
text-align: right;
flex: 0 0 calc(4 * var(--report-font-size));
white-space: nowrap;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you look closely, the "after" sparkline no longer lines up at the end. This is the same result as just deleting the flex: property above, but defeats the purpose of the rule: these sparklines need to line up across these isolated flex containers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that was intentional, in the original PR. Also I think if we use tables for rendering tables, this issue might not have occurred.

I've updated the PR with 5 and removed nowrap.

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

Based on my review comments, I think this should be fixed by (for now) just bumping 4 * -> 5 * in the flex: property.

@alexnj alexnj merged commit 6de2ed2 into main Jan 26, 2023
@alexnj alexnj deleted the nowrap-sec branch January 26, 2023 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants