-
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
BorderControl: always show Reset button #69066
BorderControl: always show Reset button #69066
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. |
@@ -147,6 +147,12 @@ export const borderControlPopoverControls = css` | |||
export const borderControlPopoverContent = css``; | |||
export const borderColorIndicator = css``; | |||
|
|||
export const clearButton = css` |
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.
Reference
.components-circular-option-picker__custom-clear-wrapper { | |
display: flex; | |
justify-content: flex-end; | |
margin-top: $grid-unit-15; | |
} |
cc @WordPress/gutenberg-components |
Thank you for the ping! Here are a few thoughts:
What do y'all think? |
I think this is a very good idea. If it's okay to always display the reset button, I'll delete the |
Thank you. I adjusted it.😌 |
<div className={ clearButtonClassName }> | ||
<Button | ||
className={ resetButtonClassName } | ||
variant="tertiary" | ||
onClick={ () => { | ||
onReset(); | ||
onClose(); | ||
} } | ||
disabled={ ! showResetButton } | ||
accessibleWhenDisabled | ||
__next40pxDefaultSize | ||
> | ||
{ __( 'Reset' ) } | ||
{ __( 'Clear' ) } | ||
</Button> | ||
</DropdownContentWrapper> | ||
) } | ||
</div> | ||
</DropdownContentWrapper> |
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.
Are these DOM / layout changes necessary?
- Adding an extra
div
around the reset button - moving the reset button as a child of
DropdownContentWrapper
- renaming and restyling the reset button to the clear button?
In other words, it seems to me that the main issue was the "reset" button being added and removed from the DOM.
If we change the logic from
{ showResetButton && (
<DropdownContentWrapper paddingSize="none">
<Button {...buttonProps} />
</DropdownContentWrapper>
) }
to
<DropdownContentWrapper paddingSize="none">
<Button {...buttonProps} accessibleWhenDisabled disabled={!showResetButton}/>
</DropdownContentWrapper>
wouldn't that be enough?
Is the change from "Reset" to "Clear" necessary, including the UI/layout change?
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 review!
Are these DOM / layout changes necessary?
gutenberg/packages/components/src/circular-option-picker/circular-option-picker.tsx
Lines 165 to 169 in 3f0a805
const actions = actionsProp ? ( <div className="components-circular-option-picker__custom-clear-wrapper"> { actionsProp } </div> ) : undefined;
I think this is necessary to align the button to the right.
I used circular-option-picker as a reference.
renaming and restyling the reset button to the clear button?
This was also based on circular-option-picker.
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.
@ciampo
What do you think?
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 may be missing context, but was there a specific request to make it look like CircularOptionPicker
?
If the main need for this PR is to fix UI jumpiness and a11y around a button being added/removed from the DOM, then I'd keep design changes out of the PR scope.
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.
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.
There are still design differences compared to what's on trunk
, but I think they're probably the lowest effort we can make to keep the design working — if we kept the "reset" button to be full-width and with no left/right/bottom margins, the focus styles would be weird, and require even more hacky style overrides.
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.
LGTM 🚀
Let's just make sure that we rebase on top of latest trunk
and make sure that CHANGELOG changes are still in the "Unreleased" > "Enhancements" section.
Reset button is looking good when enabled:
And stays in the DOM, disabled but focusable, after being clicked
A couple of notes:
- the UI can still be jumpy because the "Style" section is hidden when the reset button is clicked;
- it's always better to iterate and test the component in isolation, and only after in the editor; to do so, we use Storybook (
npm run storybook:dev
on local machines)
packages/components/src/border-control/border-control-dropdown/component.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/border-control/border-control-dropdown/component.tsx
Outdated
Show resolved
Hide resolved
<div className={ clearButtonClassName }> | ||
<Button | ||
className={ resetButtonClassName } | ||
variant="tertiary" | ||
onClick={ () => { | ||
onReset(); | ||
onClose(); | ||
} } | ||
disabled={ ! showResetButton } | ||
accessibleWhenDisabled | ||
__next40pxDefaultSize | ||
> | ||
{ __( 'Reset' ) } | ||
{ __( 'Clear' ) } | ||
</Button> | ||
</DropdownContentWrapper> | ||
) } | ||
</div> | ||
</DropdownContentWrapper> |
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.
There are still design differences compared to what's on trunk
, but I think they're probably the lowest effort we can make to keep the design working — if we kept the "reset" button to be full-width and with no left/right/bottom margins, the focus styles would be weird, and require even more hacky style overrides.
@ciampo My research showed that a DOM change was required to style the reset button the same as the other popover components. Thank you. |
@ciampo |
What?
Closes #69065
related
#63310
#68454
Why?
The BorderBoxControl will not display the clear button unless you set the color and style.
Also, when the clear button appears, the position of the popover changes, creating a small amount of stress.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Before
before.mp4
After
after.mp4