Conversation
| const classes = cx( | ||
| 'components-toggle-control', | ||
| className, | ||
| ! __nextHasNoMarginBottom && css( { marginBottom: space( 3 ) } ) |
There was a problem hiding this comment.
For back compat, we set a custom value (12px) here instead of simply passing through the __nextHasNoMarginBottom to BaseControl. This is because ToggleControl was setting a custom margin-bottom value (12px) that was different from BaseControl's margin-bottom (8px).
|
Size Change: -87 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
素晴らしい 🚀
We can merge once test failures are addressed
(also, pinging @jasmussen as promised in #39209 (comment))
| import ToggleControl from '../'; | ||
|
|
||
| describe( 'ToggleControl', () => { | ||
| it( 'triggers change callback with numeric value', () => { |
There was a problem hiding this comment.
Curious test name, I don't understand the "numeric value" part
| render( <ToggleControl label="My toggle" onChange={ () => {} } /> ); | ||
| expect( | ||
| screen.getByRole( 'checkbox' ) | ||
| ).not.toHaveAccessibleDescription(); |
cb823cf to
acd3541
Compare
| .components-base-control { | ||
| .components-base-control__field { | ||
| align-items: center; | ||
| display: flex; | ||
| margin-bottom: 0; | ||
|
|
||
| & > label { | ||
| flex-grow: 1; | ||
| padding: 0.6rem 0 0.6rem 10px; | ||
| } | ||
| } | ||
| & + & { | ||
| margin-top: $grid-unit-20; | ||
| } | ||
|
|
||
| .components-base-control__help { | ||
| margin: -$grid-unit-10 0 $grid-unit-10 58px; | ||
| font-size: $helptext-font-size; | ||
| font-style: normal; | ||
| color: $gray-700; |
There was a problem hiding this comment.
Chipping at it a little bit at a time ⏳
| "src/search-control", | ||
| "src/snackbar", | ||
| "src/tab-panel", | ||
| "src/toggle-control", |
|
Storybook looks good to me. That is — I don't see anything wrong with the toggle control. |
|
In my review I missed the case where the toggle has help text. This is how the toggle use to look with the spacing between toggle and help text: This is how it looks now: The space may have been a teensy bit too big in the previous case — it should be 8px — but it's gone at the moment. Sorry for not catching this! |
No worries, that style breakage is due to overrides in the Inspector, not the component itself. It should be fine in Storybook. I'll see what I can do about the override breakage. |


Part of #35744 #38730
What?
__nextHasNoMarginBottomprop for removing margins.Why?
Better devex.
Testing Instructions
npm run storybook:devand check the stories for ToggleControl.Note that the space between the toggle and the
helptext is narrower than on trunk. This is intentional, to address #39209 (comment).