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

PageHeader: Fixes layout issues on title and sub components #4669

Merged
merged 15 commits into from
Jun 26, 2024

Conversation

broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Jun 12, 2024

Important

For release coordinator: I would need two commits (commit1, commit2) to be added to the upgrade PR

Reported internally on Slack (Hubbers link only) that there is a layout shift happening on titles and sub components. (font-size (for titles) and the height of the actions change after the initial render)

Video describes the layout shift issue in the prod storybook and how this PR fixes it on the local environment. Especially the actions on the right side jumps quite visibly.

Rewatch.Screen.Recording.-.2024-06-10.at.1.57.mp4

Changelog

New

Changed

  • Updates root styles to select elements that has data-component="TitleArea" and each related variant data attribute, and sets the font styling and height for sub components (leading actions, actions etc) for each variant. Since we don't need to wait for any render as we did before, we don't see any layout shift.
  • Since we set the font styles on TitleArea (as described just above), we don't hit specificity issues when there is an override on the Title (like the reported issue), therefore no layout shift on the titles either.

Removed

  • Removes retrieving the variant value from PageHeader.TitleArea in the useeffect.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

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
  • (GitHub staff only) Integration tests pass at github/github - https://github.com/github/github/pull/328861 Performed manual testing at dotcom and can confirm that all is working fine 👍🏻

Copy link

changeset-bot bot commented Jun 12, 2024

🦋 Changeset detected

Latest commit: 4ce72c2

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 Patch

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

Copy link
Contributor

github-actions bot commented Jun 12, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 91.1 KB (0%)
packages/react/dist/browser.umd.js 91.35 KB (0%)

@@ -435,6 +395,9 @@ const Breadcrumbs: React.FC<React.PropsWithChildren<ChildrenPropTypes>> = ({
return value ? 'none' : 'flex'
}),
alignItems: 'center',
fontWeight: 'initial',
lineHeight: 'var(--text-body-lineHeight-large, 1.5)',
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be using var(--text-body-lineHeight-medium, 1.4285)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry I missed to update that! Just pushed it.

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.

In the VRT snapshots, the text next to the "Open" badge looks vertically off-center, but I'm not actually seeing this when I look at the preview deployment. I checked this in Chrome, Safari, and Firefox.

Screenshot 2024-06-25 at 4 32 11 PM

@broccolinisoup
Copy link
Member Author

@mperrotti yeah it is interesting! I can confirm that I see the same thing as you shared. It might be because of the font settings etc are different where these snapshots are generated.

@broccolinisoup broccolinisoup added this pull request to the merge queue Jun 26, 2024
Merged via the queue into main with commit 1403ef7 Jun 26, 2024
36 checks passed
@broccolinisoup broccolinisoup deleted the pageheader-layout-shift branch June 26, 2024 05:20
@primer primer bot mentioned this pull request Jun 26, 2024
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.

None yet

2 participants