Skip to content
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

Merged
merged 11 commits into from
Feb 15, 2025

Conversation

shimotmk
Copy link
Contributor

@shimotmk shimotmk commented Feb 5, 2025

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

  1. Go to post or page
  2. Set borders for paragraph blocks, etc.
  3. You can see that the Clear button is always visible.

Testing Instructions for Keyboard

Screenshots or screencast

Before

before.mp4

After

after.mp4

Copy link

github-actions bot commented Feb 5, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: shimotmk <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: yogeshbhutkar <[email protected]>

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`
Copy link
Contributor Author

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;
}

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Feature] UI Components Impacts or related to the UI component system Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Feb 6, 2025
@Mamaduka
Copy link
Member

Mamaduka commented Feb 6, 2025

cc @WordPress/gutenberg-components

@ciampo
Copy link
Contributor

ciampo commented Feb 6, 2025

Thank you for the ping! Here are a few thoughts:

  • The change is actually on BorderControl, not BorderBoxControl
  • We prefer working on the @wordpress/components package in isolation from the rest of the Gutenberg app for better separation of concerns and better testing (ie. unit tests, Storybook). It would be great if we could move the changes to the rest of Gutenberg to a separate PR;
  • Why don't we always show the existing "Reset" button? We keep it "accessible but disabled" while there are no values to reset, and otherwise enabled when there are values to reset. We can do that by reusing the logic used in the showResetButton variable, and instead of using it to conditionally render the button, we use it to conditionally disable that same button. No need to add extra props and deprecation warnings.

What do y'all think?

@shimotmk
Copy link
Contributor Author

shimotmk commented Feb 6, 2025

We keep it "accessible but disabled" while there are no values to reset, and otherwise enabled when there are values to reset.

I think this is a very good idea.
I was worried that some people might like the old format, so I created a process that works the same as before in the deprecated process.

If it's okay to always display the reset button, I'll delete the showClearButton props.

@shimotmk shimotmk changed the title BorderBoxControl: always show clear button BorderControl: always show clear button Feb 7, 2025
@shimotmk
Copy link
Contributor Author

shimotmk commented Feb 7, 2025

Thank you. I adjusted it.😌

Comment on lines 225 to 238
<div className={ clearButtonClassName }>
<Button
className={ resetButtonClassName }
variant="tertiary"
onClick={ () => {
onReset();
onClose();
} }
disabled={ ! showResetButton }
accessibleWhenDisabled
__next40pxDefaultSize
>
{ __( 'Reset' ) }
{ __( 'Clear' ) }
</Button>
</DropdownContentWrapper>
) }
</div>
</DropdownContentWrapper>
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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.

CircularOptionPicker

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply. Indeed, I changed Clear back to Reset as it was not a good idea to include it in this PR!
border

Copy link
Contributor

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.

@shimotmk shimotmk changed the title BorderControl: always show clear button BorderControl: always show Reset button Feb 13, 2025
Copy link
Contributor

@ciampo ciampo left a 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:

Screenshot 2025-02-14 at 15 02 56
And stays in the DOM, disabled but focusable, after being clicked

Screenshot 2025-02-14 at 15 03 05

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)

Comment on lines 225 to 238
<div className={ clearButtonClassName }>
<Button
className={ resetButtonClassName }
variant="tertiary"
onClick={ () => {
onReset();
onClose();
} }
disabled={ ! showResetButton }
accessibleWhenDisabled
__next40pxDefaultSize
>
{ __( 'Reset' ) }
{ __( 'Clear' ) }
</Button>
</DropdownContentWrapper>
) }
</div>
</DropdownContentWrapper>
Copy link
Contributor

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.

@shimotmk
Copy link
Contributor Author

@ciampo
This has been improved.
#69066 (comment)
#69066 (comment)

My research showed that a DOM change was required to style the reset button the same as the other popover components.
#69066 (comment)

Thank you.

@ciampo ciampo merged commit 388d664 into WordPress:trunk Feb 15, 2025
59 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.4 milestone Feb 15, 2025
@shimotmk
Copy link
Contributor Author

@ciampo
Thanks for the review!

@shimotmk shimotmk deleted the fix/border-box-control-clear-button branch February 15, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BorderBoxControl clear button not always visible
3 participants