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

Tabs and ToggleGroupControl: round indicator size #66426

Merged
merged 4 commits into from
Oct 25, 2024
Merged

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Oct 24, 2024

What?

Fixes #66347

This PR adds rounding to the Tabs and ToggleGroupControl's indicators

Why?

As demonstrated in #66347, the indicator can sometimes cause scrolling in its container (eg. tablist) in an unreliable way, caused by subpixel rendering.

How?

  • added a roundRect option to the useAnimatedOffsetRect hook which applies Math.floor to the rect measurements;
  • enabled the option in Tabs and ToggleGroupControl components

Testing Instructions

Follow instructions from #66347, make sure the issue can't be reproduced while applying changes from this PR.

Screenshots or screencast

Kapture.2024-10-24.at.17.15.21.mp4

@ciampo ciampo added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Oct 24, 2024
@ciampo ciampo requested review from stokesman and a team October 24, 2024 15:34
@ciampo ciampo self-assigned this Oct 24, 2024
Copy link

github-actions bot commented Oct 24, 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: stokesman <presstoke@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org>

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

Copy link
Contributor

@stokesman stokesman left a comment

Choose a reason for hiding this comment

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

I tested and this fixes the issue.

I was curious if this might be a candidate for 6.7 but I can’t reproduce the issue on 6.7 RC1. That’s a bit of a curiosity since at least some of the recent Tabs updates seem to have landed there. I mostly mention that as something that could be investigated to figure out precisely why the issue is in trunk and not there. The unrounded values seem to be present in 6.7 yet not producing this issue.

Anyway, this seems like a solid fix especially because all property values are floor’d.

@stokesman
Copy link
Contributor

  • added a roundRect option to the useAnimatedOffsetRect hook which applies Math.floor to the rect measurements;

It almost feels like it could be a string type so it could be specified to either "ceil"|"floor"|"round" but I'm sure it’s fine as is for now. It’s not easy to imagine those other options being too useful, just that the name roundRect is more generic than what’s implemented (flooring). I suppose if we’re sure flooring is always going to be the only worthwhile option we could consider naming it "roundDownRect" 😆 or something else.

@ciampo
Copy link
Contributor Author

ciampo commented Oct 25, 2024

Thank you for the review!

This can't be reproduced in 6.7 because not all recent Tabs work was backported (see this convo) — so I'd say it's expected.

Re. the rounding options and variable name, you have a point — but I think that the current solution is good enough for the time being, and I don't anticipate a need for more nuance (if anything, we may want to remove the option and always floor the measurements)

@ciampo ciampo merged commit 808195d into trunk Oct 25, 2024
64 checks passed
@ciampo ciampo deleted the fix/tabs-scroll branch October 25, 2024 09:54
@github-actions github-actions bot added this to the Gutenberg 19.6 milestone Oct 25, 2024
@ciampo
Copy link
Contributor Author

ciampo commented Oct 28, 2024

I realized I never added a link in my previous message — this is the conversation with a detailed list of what Tabs changes made it to the 6.7 release, and which ones didn't.

karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@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] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tabs obscure unintentional horizontal overflow
2 participants