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.
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
Tabs: indicator animation #60560
Tabs: indicator animation #60560
Changes from 19 commits
898f29d
ce628d3
7e43c02
47f029d
0a66bbd
3dae51c
a0b0581
a5d5d27
22909d8
77d208f
e9ccc02
283f109
b3ab95f
45d8215
f364cc2
f0a5a65
539be1e
fa9f34e
16fac9f
6b2f541
aa6e66b
2f14f6d
02099ac
2c4d085
59523e4
bed8a36
f0b896b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What difference does it make if I just call
onUpdate?.()
here (and add it as a dependency of course)? It's not immediately clear why we need theupdateCallbackRef
in the first place.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.
Similar logic to #60560 (comment), though in this case due to how the effect is implemented (idempotently) it wouldn't really break anything, but it would cause wasteful computation since there's an unnecessary dependency for the effect.
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.
Why do we need to maintain the update callback in a ref? What difference would it make if I did:
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.
This is a low-level event-oriented hook that needs to fire only on value updates. If the callback was a dependency for the effect, passing a different callback would trigger it, ergo the hook would not be firing on value updates exclusively. That would be misleading, and would also break the logic of consumers. In our case, such scenario would cause the animation to be enabled at a time when it shouldn't be.
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.
Btw, @jsnajdr also proposed this as I was about to push a commit with it, we had a parallel thinking moment :P #60560 (comment)
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.
Looking at the code, I'd always expect animations. However, there are cases when animations won't be there, for example:
Should we document these and set the right expectations that animations are expected only for vertical tabs and when
prefers-reduced-motion
is not enabled?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.
No animations with
prefers-reduced-motion
should be expected in every place where we have animations, and it's made explicit in the CSS. I don't personally feel like any further documentation is necessary in that front, unless we decide to do it consistently. However, we don't really have user-facing documentation in the first place for individual components anyway :PVertical tabs actually do have an animation. I might change this if we don't want the change (as discussed somewhere else in this review's comment), but currently it does, and it works in the same way except vertically (in the right side).
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.
Is this something we need to handle in the component itself? Perhaps if we provide an API to declare the indicator to be optional?
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.
This seems like an escape hatch and it's only used here. You could also say the same about everything else that's being customized or overriden here (a lot). I would advise against supporting this to prevent configuration-creep from building up. If this pattern becomes "official" or, at least, common enough, then I would agree.
At the root of this I think the problem is that
Tabs
from@wordpress/components
is not what was needed here. Rather, it seems like we need tabs that look a certain way, and for that it seems like using Ariakit with the styles wanted for this interface is the way to go.