Button: Properly handle border radius reset#23887
Conversation
|
@njbrown Thank you for working on this! ❤️
@youknowriad I took a look. There's something odd about the reset mechanism of this component. I remember helping fix something There's also a Ideally, the consumer of this component shouldn't have to manually interpret change callbacks to manage resets. Digging through the closed issues.. the previous bug came from Looking at the previous implementation 🤔 It looks like the reset action caused As a next step, I'll observe and track issues related to For now, I think this update works. Does that sound good? Thanks! |
|
Yes, that sounds good to me. |
|
Congratulations on your first merged pull request, @njbrown! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
| setAttributes( { | ||
| borderRadius: initialBorderRadius, | ||
| } ); | ||
| else setAttributes( { borderRadius: newBorderRadius } ); |
There was a problem hiding this comment.
It's weird that this passes the linting checks, I thought {} were enforced.
There was a problem hiding this comment.
Not a big deal, but if folks think it could be a good rule we can see if we should add it.
Description
When the reset button of the border radius slider is clicked, the button in the editor doesn't reflect the change. This bug exists because the
RangeControlcomponent passedundefinedto itsonChangecallback when the reset button is hit and this condition was not handled.This pr fixes it by capturing the initial value of the border radius of the button then resets to it to that value when the reset button is pressed.
How has this been tested?
Add a Button
Change the value of the border radius
Hit the reset button beside the border radius slider
Screenshots
before fix:

after fix:

Types of changes
Bug Fix
Checklist: