-
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
Tabs: Prevent accidental overflow in indicator #61979
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in 7d82754. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9234935079
|
Good catch, this won't work though. The use of offset sizes is intentional since the bounding rect approach causes glitches when combined with transformations and such. Offset sizing properties are not affected by this, and though subpixel precision would be nice it doesn't really seem that important. As a fix for this, I would simply propose doing Thanks for noticing and sending a fix! Want to try my suggestion here? |
Of course, please feel free to push 👍 |
@DaniGuardiola Is it possible to move the PR forward? I believe this issue needs to be fixed in WP6.6. |
@t-hamano ah, yes, missed your last comment. Happy to push my proposed fix in a bit. |
@t-hamano I've pushed the "naive" solution I proposed, but I am exploring a better solution where we could still have subpixel precision: https://stackblitz.com/edit/solidjs-templates-oerxnc?file=index.html,src%2FApp.tsx,src%2Findex.tsx |
…abs/decimal-point-indicator
@t-hamano okay, this is the best I could do. I've tested it and it fixes the issue. I wish we could find a "perfect" solution with completely accurate values, but this'll have to do. FYI, if you want to give it a last try, the goal is to get a computed "top" value that is accurate in the stackblitz I created (linked in the previous comment) - has to remain accurate also when transformed. |
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.
Code-wise this makes sense to me 👍 Thanks!
@t-hamano if you could confirm this resolves the horizontal scroll issue in your testing, feel free to 🚢 .
@DaniGuardiola Thanks for the update! In my environment, the width of the sidebar with the scrollbar is BeforeAfter |
@t-hamano seems correct, yes. |
…dd/on-async-directives * 'trunk' of https://github.com/WordPress/gutenberg: (72 commits) Top toolbar: fix half a pixel artifacting of the bottom border. (#62225) Fix UI order for theme.json spacing sizes (#62199) Chore: Simplify a padding style on global styles. (#62291) Editor: Avoid remounts of `DocumentBar` (#62214) Add `default-spacing-sizes` and `default-font-sizes` options for classic themes (#62252) Editor: Cleanup styles and classnames (#62237) Scripts: Pin the @wordpress/scripts version to a version supported by WP 6.5 (#62234) Documentation: Better changelogs for the JSX transform upgrade (#62265) Chore: Simplify a padding style on dataviews. (#62276) MediaUpload: Remove dialog markup on close (#62168) Tabs: Prevent accidental overflow in indicator (#61979) Make edit site pagination buttons accessibly disabled. (#62267) Fix: Remove unused code from dataviews styles. (#62275) Re-enable React StrictMode (#61943) Inserter: Return the same items when the state and parameters don't change (#62263) Update instances of text-wrap: pretty to fall back to balance (#62233) Update: Slotfill documentation samples (links, code, and rephrase). (#62271) Try: Fix mover positioning. (#62226) [Mobile] - Image corrector - Check the path extension is a valid one (#62190) Update: Block styles documentation. ...
* Tabs: Consider decimal point in indicator style * Update changelog * Naive solution. * Subpixel size and position workaround. * Add comment. * Move CHANGELOG entry to Unreleased section --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
* Tabs: Consider decimal point in indicator style * Update changelog * Naive solution. * Subpixel size and position workaround. * Add comment. * Move CHANGELOG entry to Unreleased section --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
* Tabs: Consider decimal point in indicator style * Update changelog * Naive solution. * Subpixel size and position workaround. * Add comment. * Move CHANGELOG entry to Unreleased section --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
This was cherry-picked to the wp/6.6 branch. |
What?
This PR takes the decimal point into account when calculating the indicator's style (top, left, width, height) to prevent the indicator from overflowing.
Why?
My understanding is that
offset{top|left|width|height}
rounds the decimal point. This error may cause the indicator to overflow.One problem I've seen is that inspector controls overflow on Windows OS.
The reasons why this occurs are as follows.
280px
wide.17px
. As a result, the width of the inspector control is263px
.131.5px
.131.5px
, but they are actually132px
, so the indicator overflows by 1px.How?
This could easily be solved by applyingoverflow:hidden
to the TabListWrapper, but I chose to usegetBoundingClientRect()
to generate an accurate indicator style that takes decimal points into account.In response to the feedback, a different approach was adopted - see the comments starting here for more details.
Testing Instructions
On MacOS, scrollbars have no physical width, so you won't be able to reproduce this problem by default. However, you should be able to reproduce the horizontal scroll bar issue on MacOS by following the steps below.
279