-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Popover: set is-positioned class only after animation has finished #54178
Conversation
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.
Nice and clean, and also well explained in the PR description. Thank you!
LGTM 🚀
packages/components/CHANGELOG.md
Outdated
@@ -8,7 +8,8 @@ | |||
|
|||
### Enhancements |
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.
Not related to this PR, but I noticed that the Enhancements header is not rendering as expected because (I believe) of a different space character than the normal one. Would you mind fixing that in this PR too? Thank you!
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.
Good catch, there was a Unicode no-break space character there (C2A0 in UTF-8) 👍
packages/components/CHANGELOG.md
Outdated
@@ -8,7 +8,8 @@ | |||
|
|||
### Enhancements | |||
|
|||
- Making Circular Option Picker a `listbox`. Note that while this changes some public API, new props are optional, and currently have default values; this will change in another patch. ([#52255](https://github.com/WordPress/gutenberg/pull/52255)) | |||
- Making Circular Option Picker a `listbox`. Note that while this changes some public API, new props are optional, and currently have default values; this will change in another patch ([#52255](https://github.com/WordPress/gutenberg/pull/52255)). | |||
- `Popover`: Add the `is-positioned` CSS class only after the popover has finished animating ([54178](https://github.com/WordPress/gutenberg/pull/54178)). |
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.
A missing #
could maybe be the reason why the CI check is failing?
- `Popover`: Add the `is-positioned` CSS class only after the popover has finished animating ([54178](https://github.com/WordPress/gutenberg/pull/54178)). | |
- `Popover`: Add the `is-positioned` CSS class only after the popover has finished animating ([#54178](https://github.com/WordPress/gutenberg/pull/54178)). |
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.
Fixed!
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.
A logical fix. Thank you, @jsnajdr!
Thank you for following this up @jsnajdr!! 🙇🏻 |
This should be the ultimate fix for the flaky popover tests (like
DotTip
) that @ramonjd has been trying to fix in #54168. The snapshot differences are caused by the fact that the popover's Framer Motion animation is still running when we are checking the snapshot, and the animated style properties likeopacity
ortranslateY
have non-deterministic values.The fix is to set the
is-positioned
CSS class on the popover element only after the animation is complete. Then the.toBePositionedPopover
Jest helper will reliably wait for the animation to finish.To achieve this, I first had to merge the
AnimationWrapper
component into the baseUnforwardedPopover
component. Their internals need to communicate with each other now, and the separation is no longer tenable.After merging, it's easy to introduce a
finishedAnimation
state variable, set by the Framer Motion'sonAnimationComplete
callback, and usefinishedAnimation
as another pre-condition foris-positioned
.We've discussed this a year ago with @ciampo and @tyxla, but at the time merging the
AnimationWrapper
was too hard. Today, after many incremental refactorings, it's possible.Note that the updated
DotTip
snapshot now correctly reflects the "animation complete" state: opacity is 1, i.e., element is fully visible, and there are notranslate
andscale
transforms.