-
Notifications
You must be signed in to change notification settings - Fork 59
fix: support padded tabs #330
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
base: master
Are you sure you want to change the base?
Conversation
🟡 Heimdall Review Status
🟡
|
| Code Owner | Status | Calculation | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ui-systems-eng-team |
🟡
0/1
|
Denominator calculation
|
| const animatedBoxStyle = useAnimatedStyle( | ||
| () => ({ | ||
| transform: [{ translateX: animatedTabRect.value.x }], | ||
| transform: [{ translateX: animatedTabRect.value.x }, { translateY: animatedTabRect.value.y }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On mobile we only needed to track the y value
| data-testid="tabs-active-indicator" | ||
| height={height} | ||
| initial={false} | ||
| left={0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On web we only needed to set the left offset to 0, so that the logic for tracking position doesn't add the left offset on top of the default padding. This isn't a worry for y since we aren't animating by y it will simply use the default padding.
We could in theory adjust the activeTabRect above to track y and update active animation as well and then we would need to add top={0}. But this is a simpler solution.
What changed? Why?
This change enables support for using padding props on Tab related components, including SegmentedTabs and PeriodSelector.
This request came in by a user wanting to use PeriodSelector with padding. While I do not foresee users wanting to add padding to SegmentedTabs, it is much easier to visualize the issue there as it has a background.
Root cause (required for bugfixes)
On web we were "double counting" padding by having the active indicator be offset by padding and then adding it to our x value. This meant that it would be too far over to the right.
On mobile we weren't setting the y value of the element, since it needed explicit x/y offset. This meant that it would sit at the top, not impacted by padding.
We fixed these by setting left={0} on web and on mobile setting the y value of the active indicator.
UI changes
Testing
How has it been tested?
Testing instructions
Illustrations/Icons Checklist
Required if this PR changes files under
packages/illustrations/**orpackages/icons/**Change management
type=routine
risk=low
impact=sev5
automerge=false