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

CircularOption: Avoid paint on circular option hover #46197

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

corentin-gautier
Copy link
Contributor

@corentin-gautier corentin-gautier commented Nov 30, 2022

What?

Avoid browser paint when hovering the circular-option-picker

How?

A simple will-change: transform

Testing Instructions

  1. Open the dev console and enable the paint flashing (under rendering)
  2. Open a color palette popover
  3. Hover over a color
  4. There should not be paint on the circular options

Screenshot

Before

Screen.Recording.2022-11-30.at.15.05.56.mov

After

Screen.Recording.2022-11-30.at.15.06.55.mov

@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @corentin-gautier! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 30, 2022
@skorasaurus skorasaurus added the [Type] Performance Related to performance efforts label Nov 30, 2022
@ciampo ciampo added the [Package] Components /packages/components label Nov 30, 2022
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.

Thanks for your work here @corentin-gautier! Also, I appreciate you splitting the changes into multiple PRs!

@@ -26,6 +26,7 @@ $color-palette-circle-spacing: 12px;
vertical-align: top;
transform: scale(1);
transition: 100ms transform ease;
will-change: transform;
Copy link
Member

Choose a reason for hiding this comment

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

All sources of documentation (for example https://developer.mozilla.org/en-US/docs/Web/CSS/will-change#via_script and ) I read about will-change suggest that we add it programmatically and remove it after it's served its purpose, rather than having it enabled by default.

Have you considered adding it as a one-off effect in this component and then removing it on cleanup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tyxla You're thinking of adding it when the popover opens ? We can use a translateZ(0) instead of will-change to get the same result !

Copy link
Contributor

Choose a reason for hiding this comment

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

Have we tested adding it only on hover/focus ? Or what about using the contain CSS property instead?

Copy link
Member

Choose a reason for hiding this comment

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

I think adding it on :hover/:focus can be too late since the browser won't be able to do the optimizations before performing the actual element transformation.

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.

This looks great 🚀 Thanks @corentin-gautier!

One thing we could explore is adding will-change: transform in the component at mount time and then removing it at cleanup/unmount time, but I didn't see a reason to do that. The only reason to think it could be an improvement is the corresponding suggestion in its docs. It's fine to take it step by step though!

🚀

@tyxla tyxla merged commit 8c44ccb into WordPress:trunk Dec 2, 2022
@corentin-gautier corentin-gautier deleted the fix/circular-option-paint branch December 2, 2022 10:55
@github-actions github-actions bot added this to the Gutenberg 14.8 milestone Dec 2, 2022
mpkelly pushed a commit to mpkelly/gutenberg that referenced this pull request Dec 7, 2022
@ryanwelcher ryanwelcher changed the title Avoid paint on circular option hover CircularOption: Avoid paint on circular option hover Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Components /packages/components [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants