-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix: Align tooltip with others element spacing wise #64454
base: trunk
Are you sure you want to change the base?
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
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. |
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.
Thanks for the PR!
I think adding styles to the Tooltip
component that depend on specific text should be avoided for the following reasons:
- The
Tooltip
component should not depend on a specific context - The text may be localized and changed to a different text
- It also affects other tooltips that contain text such as
up
anddown
- The tooltip is not guaranteed to appear at the bottom
The current Tooltip component has a hardcoded gutter. My thought is that there may need to be a prop like offset
or tooltipOffest
to modify this gutter in some way, like in the Popover
component.
cc @WordPress/gutenberg-components
Hey @t-hamano |
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.
Unfortunately, I don't think this is the way to go.
I'd recommend trying to adjust the component that consumes the Tooltip
, because this is a particular scenario related to a very specific use case.
Furthermore, if we were to add spacing to Tooltip
s, I'd expect we do it in a consistent way that applies to all of them.
Thanks @tyxla for the review |
Thanks for your hard work on it @Rishit30G 🙌 |
Updates on PR as per feedback 📝
Sharing the screencast for the same: Screen.Recording.2024-08-13.at.12.40.15.PM.mov |
@@ -110,6 +110,7 @@ export function UnforwardedButton( | |||
children, | |||
size = 'default', | |||
text, | |||
tooltipDirection, |
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.
Note that there is already a tooltipPosition
prop on Button
that can you can use to change the tooltip placement (e.g. "top"
and "bottom"
).
I don't think we will need any changes in the @wordpress/components
package to land this PR. As for fine-tuning the "bottom" placement so the block mover down tooltip aligns with the other toolbar button tooltips, I think a cleaner strategy would be to fix the metrics of the block mover buttons so their vertical edges are aligned with the other buttons. If you add a visible outline to the buttons, you can see that the block mover buttons are shorter. This is causing the misalignment of the tooltips.
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.
Hi @mirka, Agree on this, We just need to adjust this style added here which make this height -
height: $block-toolbar-height * 0.5 - $grid-unit-05; |
24px
, by removing the $grid-unit-05
, not sure why this added, may be to decrease the space between chevrons,
Also, need to adjust the top and bottom padding for up
and down
button to 10px
, so that it looks what it looked like earlier.
@Rishit30G, Could you please adjust this style and check if it helps,
The move up
, would still not in place, but move down
would be consistent with different toolbar tooltips.
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.
Agreed @mirka's suggestions are the way to go. We should use what we have and keep any specific customization outside of the Tooltip
component.
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.
Thanks for the suggestions @mirka, @hbhalodia, @tyxla 🙇
- I have removed extra
tooltipDirection
and usedtooltipPosition
- Updated the style from
height: $block-toolbar-height * 0.5 - $grid-unit-05;
toheight: $block-toolbar-height * 0.5;
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 "$grid-unit-05", not sure why this added
This style was added when introducing a custom scrollbar to the block toolbar in #57444 (Sorry for not leaving a comment 🙇♂️).
If we remove $grid-unit-05
, an unnatural shift will occur when the mover button is focused on Windows OS:
500cb196af93dc4912fdc5a684188eac.mp4
We tried a lot of different things to fix this problem in #57444, but for now, I think it's better not to remove $grid-unit-05
.
Of course, if the top toolbar is disabled, there's no problem with removing $grid-unit-05
, but if adjusting the tooltip position becomes complicated, I think it's better to leave $grid-unit-05
.
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.
Thanks for the info @t-hamano! 🙌🏻
I already made a workaround for this in previous commits, will see if I can incorporate it without breaking
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.
Fixed ✅
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.
Hey @Rishit30G , I agree with @mirka 's suggestions above, especially about
I don't think we will need any changes in the
@wordpress/components
package to land this PR
Can we make sure this PR doesn't include changes to Button
and Tooltip
? Thank you 🙏
Thanks for sharing the inputs! 🙇 |
What?
This PR is intended to fix: #64440
How?
Added specific styles to
Move Up
andMove Down
LabelsTesting Instructions
Screenshots or screencast
Screen.Recording.2024-08-12.at.1.25.47.PM.mov