-
Notifications
You must be signed in to change notification settings - Fork 4.7k
BorderBoxControl: Ensure most common unit selection is maintained #44565
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
BorderBoxControl: Ensure most common unit selection is maintained #44565
Conversation
|
Size Change: +266 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
ciampo
left a comment
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.
Changes LGTM and test well as per instructions — also extra kudos for the additional unit tests!
My only doubt in terms of UX is the discrepancy in the logic when the controls are re-linked:
- we make an opinionated choice for the unit
- we keep the width and the style "mixed"
Also, Since BorderBoxControl's logic looks very similar to the one in BoxControl, BorderRadiusControl (in the @wordpress/components package) and SpacingSizesControl (in the @wordpress/block-editor package), are these changes something that should be applied to those components as well?
Not for this PR, but @mirka and I had already discussed with @glendaviesnz about working on a base component that can abstract the common parts that these components share. It would be great if we could start planning for that too
|
Thanks for the review @ciampo 👍
I had similar doubts as well but if we are to keep the unit select around when the control has mixed values, this PR's approach felt the most natural to me. If the user has gone to the trouble of setting non-px units, it's a little annoying to switch back to the linked view and go to "unify" the border widths but have to reselect the unit again because it was set to All that said, I'm happy to adjust it in a follow-up if anyone has a better option. It is also worth noting that the potential removal of the unit select when the control has mixed values was floated in #41860. In that PR, I'm trying to increase the border controls to 40px in height. The increased padding that comes with that size variant means we no longer have space for the 'Mixed' placeholder, for example. Removing the unit select in that situation would free up some real estate. For this component, it would also then make the unit "mixed" as per width value, color, and style.
I believe those components already maintain the most common unit as the selected unit when they have mixed values.
Agreed. I had those same discussions with Glen when he started out on the spacing presets UI. I'll happily take a run at it once I have the bandwidth if no one else has already picked it up. |
|
For sure this bit of UX is tricky, happy to iterate in the future as we keep using this component and gaining more insights |
Related:
What?
Updates the
BorderBoxControlsuch that when it contains "mixed" border values, it maintains the most common unit selection when switching back to the "linked" view.Why?
Having the "linked" control display 'px' as the selected unit when split borders might all be using different CSS units is confusing. This PR brings it more in line with the box control while still maintaining the border control specific behaviour.
How?
getCommonBorderutil to return a "CSS unit-only" value for mixed widths so theUnitControlmaintains an appropriate unit selection.Testing Instructions
BorderBoxcontrolunit tests:npm run test:unit packages/components/src/border-box-control/testScreenshots or screencast
Screen.Recording.2022-09-29.at.3.37.15.pm.mp4
Screen.Recording.2022-09-29.at.3.45.46.pm.mp4