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
Top Toolbar: Prevent the focus outline of the button from being cut off #54172
Conversation
? parseFloat( computedPinnedItemsStyle.width ) + 10 // 10 is the pinned items padding | ||
? parseFloat( computedPinnedItemsStyle.width ) |
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.
Padding is included in the width value, so it shouldn't be necessary in the first place.
f377768
to
d0c20a7
Compare
Size Change: -46 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
overflow: hidden; | ||
} | ||
} | ||
|
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.
I don't understand the connection between the two changes. If the 10 px extra width solves the focus ring issue why do we need to remove this tweak? As far as I know this was added to prevent thr ugly jumping around when scrollbars appear.
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.
The scrollbars in the sidebar are defined elsewhere and are not affected by removing this CSS. This CSS affects the header. The following screencast might help you understand why this style must be removed.
We could take this scrollbar width into account when calculating the width of the fixed toolbar, but this is a bit tricky. See ChatGPT's answer for more details 😅: https://chat.openai.com/share/08933117-0064-4de0-ae71-747550c00c55
69cfa5fbf4f583a9a3b06352be25178b.mp4
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.
I can't reproduce the problem on OSX but OTOH the PR does not break anything either for me so 👌🏻
Thanks for the review, @draganescu! This problem is probably unique to WIndows, where the scrollbar has a physical width. I believe we can safely merge this PR, but if there are other issues I would be happy to address them in a follow-up! |
What?
This PR prevents the focus outline of the device preview button from cutting off when the top toolbar is enabled.
Site Editor
Before
After
Post Editor
Before
After
Why?
Site Editor
The fixed toolbar dynamically has its own width, minus the total width of the other UI in the header, margins, etc. However, when the first button (device preview button) in the right header is focused, the outline has a width of 2px, so it is hidden under the top toolbar.
Post Editor
The Post Editor is a little more complicated. In #47177, the sidebar now always has the scrollbar to prevent sidebar UI shifting. At the same time,
scrollbar-gutter: stable;
was added to align the header icons with the sidebar. This will push the right-hand header to the left by the width of the scrollbar. As a result, even if the top toolbar has the correct width, it will overlap by the width of this scrollbar.How?
Site Editor
When calculating the fixed toolbar width, I took the outline into account and subtracted 2px.
Post Editor
Removed
scrollbar-gutter:stable
from the right header. This causes problems in Windows OS and Mac OS (where scrollbars are always set to appear), where the scrollbar has a physical width that prevents the header and sidebar icons from aligning.However, this approach also has the effect of removing unnecessary spacing on the right side of the header when the sidebar is not displayed.
So far I haven't found an approach that would ideally solve everything, so if anyone has any ideas, I'd love to hear them.
Testing Instructions
Note: I've noticed an issue with the widget editor where the top toolbar obscures the header on the right. I would like to address this issue in another PR.