-
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
BoxControl
: update design
#56665
BoxControl
: update design
#56665
Conversation
There are a couple things that I'd like to run by design (cc @jameskoster) before finishing up this PR and marking it ready for review. Buttons The placement of the linked button doesn't work as well with the vertical inputs, especially if And this is how it looks if
When the Reset button is present, should it also have the 40px height when the inputs do? Input Size The input is a bit bigger than the one in SpacingInputControl. This is due to the missing settings icon. In lieu of that, do we want to: Keep it as it is now, with the UnitControl and RangeControl as equal sizes? Or add a max size of 90px to the UnitControl to match the sizing of SpacingInputControl? Or maybe a compact size option for this? And if there's any other feedback, please share! One thing to note is the Axial Controls haven't been updated with the changes yet so those will look strange right now. |
That looks great, thank you for the info and example! I initially didn't add spacing between the inputs to match the current |
56725ab
to
5fce254
Compare
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.
Overall things are looking good, although I spotted two aspects that may need improving:
- When the slider has its maximum value, both the thumb and the tooltip (shown when the thumb is focused) render partially outside of the component's boundary. This may be problematic in the sidebar, as they would either cause a horizontal scrollbar to appear, or they could be potentially cut off.
- The sliders have a fixed max value of
100
, which, depending on the selected unit, may be too little or too much. We should take inspiration fromSpacingSizesControl
and adapt max and step values per unit (see code)
Good find!
Thank you for sharing that example! I was initially concerned about using |
I see that you added an Adding more right margin would feel awkward, though. I wonder if the component would still look alright in the editor, since the sidebar should have some padding? |
aria-controls={ inputId } | ||
aria-labelledby={ inputId } |
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 based this on a similar example I saw from @andrewhayward:
<label id="lbl-2" for="ipt-2">Label 2</label>
<input id="ipt-2">
<input id="ipt-3" aria-labelledby="lbl-2" aria-controls="ipt-2">
BoxControl has very different markup, so it isn't implemented the same. In this instance, it may be completely wrong, so I would appreciate a more expert eye on this. However, this did get rid of the redundant label on the slider, while avoiding a violation for having no label.
Some additional context:
When unlinking the sides, the unit control labels are labelled by aria-labels. So I added aria-controls
and aria-labelledby
with the intention to connect it to those inputs.
In AllInputControl when it's a single/mixed set of values, there isn't an explicit label, but it inherits one from the BaseControl.VisualLabel:
gutenberg/packages/components/src/box-control/index.tsx
Lines 157 to 165 in 3192ad7
<Grid | |
id={ id } | |
columns={ 3 } | |
role="group" | |
aria-labelledby={ headingId } | |
> | |
<BaseControl.VisualLabel id={ headingId }> | |
{ label } | |
</BaseControl.VisualLabel> |
aca0be0
to
440cfd1
Compare
f8e0966
to
7fbbe43
Compare
screen.getByRole( 'group', { name: 'Box Control' } ) | ||
).toBeVisible(); | ||
expect( | ||
screen.getByRole( 'textbox', { name: 'All sides' } ) |
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 labels have been updated to be more clear, as discussed: #56665 (comment)
Context of the change:
All of the changes in 25cf3f6 will just be naming updates, except for the highlighted portion above. The change here was adding an additional assertion to still check for the input, but with the new name. Before, the label for the component (group
role) was also the label of the first input, but only when the sides were linked. Therefore the assertion would pass if the query was screen.getByRole( 'group', { name: 'Box Control' }
or screen.getByRole( 'textbox', { name: 'Box Control' }
. Which is why the query could be updated to group
from textbox
with no additional changes needed. The original labelling could be confusing when using a screenreader, with just the one input having a different labelling scheme and it being so generic.
Tl;dr, what has been changed:
So instead, now, the label implemented by the consumer for the purpose of the component will only be applied to the group
. And each input is labelled, so the linked input will now be labelled as 'All sides' or 'Mixed sides'. And unlinked will be 'Top side', 'Left side', 'Left and Right sides', etc.
packages/components/src/box-control/styles/box-control-styles.ts
Outdated
Show resolved
Hide resolved
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.
Great work wrangling all the feedback! Looks good to go once the tests are updated 👍
810cf26
to
505ac98
Compare
What?
While working on adding updated sizing in #56185, we noticed that the larger sizing affects the visibility of the input for
BoxControl
when the width is constrained. And while there is a max-width on this component, the main concern is this happens regardless due to the width of the inspector:Why?
BoxControl
is only used in the dimension panel for backward compatibility. So it was decided to change the design of the component to match custom padding when presets are provided (excluding the settings icon): #56185 (comment)How?
Since this component isn't used in many places, the main goal was to match the design specs so we could move forward with updating to the 40px sizing. So there could be potential follow-ups to reduce some redundancy currently present, but I don't believe it is a priority due to its current usage. Therefore, the main changes are:
RangeControl
component to each sideScreenshots
AllInputControl
InputControls
AxialInputControls
Will look similar but with two inputs when unlinked and the icons highlighting two sides (vertical and horizontal)
Testing Instructions
Ensure tests pass and component behaves the same as before.
For new changes:
Ensure that RangeControl updates to the correct value when typing in the input.