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

CustomSelectControlV2: animate select popover appearance #63343

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Jul 10, 2024

What?

Part of #55023

Animate the select popover appearance in the new version of CustomSelectControl

Why?

To make UI interactions feel more polished and to uniform the component with the direction taken in other components.

How?

Using CSS animations to add a fade + slide down animation when the select popover appears

Note

For now, the slide direction in the animation will always be downwards. I tried to detect when Ariakit "flips" the popover from bottom to top for lack of space, so that I could apply a "slide down" animation instead, but I couldn't extract that information from the ariakit store (I tried the same technique used in the DropdownMenuV2 component.

Testing Instructions

  1. Open the CustomSelectControlV2 Storybook default or legacy examples
  2. Open and close the select popover, make sure the animation works
  3. Using browser dev tools (or OS settings), enable the preference for reduced motion. Open and close the select popover again, and make sure that it doesn't animate.

Screenshots or screencast

Before (trunk) After (this PR)
cscv1.animation.mp4
cscv2.animation.v2.mp4

@ciampo ciampo requested a review from ajitbohra as a code owner July 10, 2024 08:49
Copy link

github-actions bot commented Jul 10, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo force-pushed the feat/custom-select-control-animation branch from 60004c1 to b65c7ee Compare July 10, 2024 08:52
@ciampo ciampo self-assigned this Jul 10, 2024
@ciampo ciampo added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Jul 10, 2024
@ciampo ciampo requested review from a team July 10, 2024 08:53
@jasmussen
Copy link
Contributor

Thanks for sweating these details.

I would expect since this is an element that opens downwards, that the animation reflect that. Right now it appears heavy on the opacity fade, and looks like it animates upwards.

@tyxla
Copy link
Member

tyxla commented Jul 10, 2024

I would expect since this is an element that opens downwards, that the animation reflect that. Right now it appears heavy on the opacity fade, and looks like it animates upwards.

Perhaps if we delay the transform part of the animation a bit?

packages/components/src/custom-select-control-v2/styles.ts Outdated Show resolved Hide resolved
@@ -13,6 +13,13 @@ import { chevronIconSize } from '../select-control/styles/select-control-styles'
import { fontSizeStyles } from '../input-control/styles/input-control-styles';
import type { CustomSelectButtonSize } from './types';

// TODO: extract to common utils and apply to relevant components
const ANIMATION_PARAMS = {
SLIDE_AMOUNT: '2px',
Copy link
Member

Choose a reason for hiding this comment

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

Should this be increased in order to make it more obvious that the select options are dropping down?

Copy link
Member

Choose a reason for hiding this comment

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

Now that you changed it to starting from - SLIDE_AMOUNT, it looks good actually 👍 Nice touch!

@ciampo
Copy link
Contributor Author

ciampo commented Jul 10, 2024

Hey @jasmussen

I would expect since this is an element that opens downwards, that the animation reflect that

Updated the animation to slide down, instead of up.

cscv2.animation.v2.mp4

Right now it appears heavy on the opacity fade

I'm not sure I understand what tweak you're suggesting to improve the fade.


Also, the opening animation is copied from DropdownMenuV2. Apart from having to refactor common variables / animations in one place (which we'll do at a later point), should I also update DropdownMenuV2 with the resulting feedback received in this PR?

@jasmussen
Copy link
Contributor

That feels substantially better! Outside of exploring actual "roll out" animations to animate the height of the dropdown from zero to its max-height, this one feels good to go as a first step.

@ciampo
Copy link
Contributor Author

ciampo commented Jul 10, 2024

this one feels good to go as a first step.

Thank you! I'll merge as soon as this PR gets an approval.

Outside of exploring actual "roll out" animations to animate the height of the dropdown from zero to its max-height,

That should be possible soon, when the transition-behavior and the @starting-style CSS features land in all major browsers (example: https://css-tricks.com/transitioning-to-auto-height/) instead of using CSS grid hacks

@ciampo ciampo requested a review from tyxla July 10, 2024 10:54
Copy link

Flaky tests detected in 449a066.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9872610839
📝 Reported issues:

@ciampo ciampo requested a review from mirka July 10, 2024 12:42
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

LGTM, nice addition 👍 👏 🚀

@@ -41,6 +41,7 @@
- `CustomSelectControlV2`: keep item checkmark top aligned. ([#63230](https://github.com/WordPress/gutenberg/pull/63230))
- `CustomSelectControlV2`: keep legacy arrow down behavior only for legacy wrapper. ([#62919](https://github.com/WordPress/gutenberg/pull/62919))
- `CustomSelectControlV2`: fix trigger button font size. ([#63131](https://github.com/WordPress/gutenberg/pull/63131))
- `CustomSelectControlV2`: animate select popover appearance. ([#63343](https://github.com/WordPress/gutenberg/pull/63343))
Copy link
Member

Choose a reason for hiding this comment

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

After rebasing to the latest trunk, we need to move this up under Unreleased.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -13,6 +13,13 @@ import { chevronIconSize } from '../select-control/styles/select-control-styles'
import { fontSizeStyles } from '../input-control/styles/input-control-styles';
import type { CustomSelectButtonSize } from './types';

// TODO: extract to common utils and apply to relevant components
const ANIMATION_PARAMS = {
SLIDE_AMOUNT: '2px',
Copy link
Member

Choose a reason for hiding this comment

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

Now that you changed it to starting from - SLIDE_AMOUNT, it looks good actually 👍 Nice touch!

@ciampo ciampo force-pushed the feat/custom-select-control-animation branch from 449a066 to 27297a0 Compare July 10, 2024 14:09
@ciampo ciampo enabled auto-merge (squash) July 10, 2024 14:10
@ciampo ciampo disabled auto-merge July 10, 2024 14:43
@ciampo ciampo enabled auto-merge (squash) July 10, 2024 14:43
@ciampo ciampo merged commit 6f5de82 into trunk Jul 10, 2024
63 checks passed
@ciampo ciampo deleted the feat/custom-select-control-animation branch July 10, 2024 14:46
@github-actions github-actions bot added this to the Gutenberg 18.9 milestone Jul 10, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
…3343)

* CustomSelectControlV2: animate select popover appearance

* CHANGELOG

* Change from slide up to slide down

* update CHANGELOG

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants