use has prop to select the titlearea and different variants #4668
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reported internally on Slack (Hubbers link only) - Please note this is the fix of the
PageHeader.Actions
layout shift issue in the PageHeader component. Not the font size which I am still working on it.The layout shift was caused by setting the
data-size-variant={titleVariant}
on PageHeader component (to set height for other sub elements such as leading and trailing visual and actions) in the useeffect. We had to do it this way in the useeffect because we only get the value of thevariant
prop after rendering thePageHeader.TitleArea
component. However, pairing with @siddharthkp yesterday, he suggested to explore usinghas
prop since we only change styles based on variants and nothing else, it simply worked! ✨This PR removes reading the
variant
value fromPageHeader.TitleArea
after the render. Instead, it simply looks for elements that hasdata-component="TitleArea"
and each related variant data attributes and set the styling for sub components under. Since we don't need to wait for any render, it simply prevents layout shift.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
I noticed this layout shift issue before but thought it is due to the slowness of the storybook but unfortunately it is quite visible in the real life too :/
Changelog
New
Changed
variant
prop fromPageHeader.TitleArea
toPageHeader
and rename it totitleVariant
Removed
Rollout strategy
Testing & Reviewing
Merge checklist