-
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
Deprecate bottom margin on BaseControl-based components #64408
Conversation
Size Change: +497 B (+0.03%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
b676d47
to
0b5efce
Compare
return ( | ||
<SelectControlWithState { ...args }> |
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.
Removed unnecessary custom render function, as this can be done via the children
arg.
if ( ! __nextHasNoMarginBottom ) { | ||
deprecated( 'Bottom margin styles for wp.components.ToggleControl', { | ||
since: '6.7', | ||
version: '7.0', | ||
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.', | ||
} ); | ||
} |
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.
ToggleControl needs to throw its own warning, because the legacy margin is added through its own custom implementation, not through BaseControl.
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. |
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've done an extensive review of all usages, tested all instances in Storybook, and did some smoke testing, and everything worked as expected ✅
Great work handling the deprecation message of all those nested cases 👏
I left a few questions and minor suggestions, and nothing of them is blocking.
Thanks for persisting through this one @mirka 🚀
packages/components/CHANGELOG.md
Outdated
@@ -2,6 +2,10 @@ | |||
|
|||
## Unreleased | |||
|
|||
### Deprecations | |||
|
|||
- Deprecate bottom margin on `BaseControl`-based components. Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version. See linked PR for full list of affected components ([#64408](https://github.com/WordPress/gutenberg/pull/64408)). |
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.
It could be a good idea to list all affected components here. IMHO it's totally fine (and actually useful to our future selves) to add one CHANGELOG line per component. Makes it easier when someone scans the CHANGELOG for suspected changes.
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.
Done in 807b1a3
@@ -31,6 +32,7 @@ const UnconnectedBaseControl = ( | |||
) => { | |||
const { | |||
__nextHasNoMarginBottom = false, | |||
__associatedWPComponentName = 'BaseControl', |
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.
Should we disallow usage of this prop outside the @wordpress/components
package? Right now, anyone can modify it, which shouldn't be allowed outside the package, IMHO. It can be a simple ESLint rule.
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 think it's fine. If anyone cares enough to use this prop it's probably for a good reason. I'm imagining an extender that has a component library using BaseControl as a wrapper, and they want to show better deprecation messages to their own consumers.
In the Gutenberg repo, any direct usages of BaseControl moving forward shouldn't throw the deprecation warning in the first place (we lint for this). So I think it's a non-issue for now.
@@ -95,6 +95,7 @@ export function CheckboxControl( | |||
return ( | |||
<BaseControl | |||
__nextHasNoMarginBottom={ __nextHasNoMarginBottom } | |||
__associatedWPComponentName="CheckboxControl" |
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.
We're adding the __associatedWPComponentName
prop only to components that can disable the __nextHasNoMarginBottom
right?
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.
Correct 👍
@@ -167,6 +169,7 @@ export const WithIntegerStepAndMarks: StoryFn< typeof RangeControl > = | |||
MarkTemplate.bind( {} ); | |||
|
|||
WithIntegerStepAndMarks.args = { | |||
__nextHasNoMarginBottom: true, |
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.
Ah, would have been nice to have an object to declare common props. Not a blocker of course.
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.
Haha yes, I considered abstracting it but decided against doing it here because it would be annoying to review it in this big PR 😂
* BaseControl: Deprecate bottom margin * Propagate to components * Missed spots * Add changelog * List all affected components in changelog Co-authored-by: mirka <[email protected]> Co-authored-by: tyxla <[email protected]>
Closes #38730 🎉 😱
What?
Start to log formal deprecation warnings on all BaseControl-based components:
Why?
To start the formal deprecation period so we can eventually switch the default behavior to the margin-free styles.
How?
For all components except for ToggleControl, the deprecation warning is thrown from the BaseControl component. The actual component name (e.g. "CheckboxControl") is passed to the BaseControl via a temporary private prop so the warning message can be more helpful.
Testing Instructions
✅ Unit tests should pass (no deprecation warnings should be thrown in the tests)
✅ No deprecation warnings should be thrown in the Storybook stories by default
You can try toggling the
__nextHasNoMarginBottom
prop in the stories to see what message gets logged in the DevTools console. The component name in the message should be correct.✍️ Dev Note
See Dev Note in #39358.