-
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
Fix toggle help indentation #63903
Fix toggle help indentation #63903
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. |
Ahh yes. This will also be helpful to have adjusted. Thanks James! |
Size Change: +214 B (+0.01%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
Flaky tests detected in e216ada. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10076859153
|
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.
This is testing well for me — although I'd like to suggest an alternative approach: instead of changing the markup in ToggleControl
, we could just add display: inline-block
to the span.components-toggle-control__help
, which would cause the margin to apply to the whole paragraph (instead of the first line).
It won't remove the additional <span>
that was pointed out in the previous PR, but it won't need to use BaseControl
's internal classnames.
Bonus: instead of margin-left
, let's use the logical equivalent margin-inline-start
.
diff --git a/packages/components/src/toggle-control/index.tsx b/packages/components/src/toggle-control/index.tsx
index c84ad90f12..89ef34f6d6 100644
--- a/packages/components/src/toggle-control/index.tsx
+++ b/packages/components/src/toggle-control/index.tsx
@@ -88,7 +88,13 @@ export function ToggleControl(
return (
<BaseControl
id={ id }
- help={ helpLabel }
+ help={
+ helpLabel && (
+ <span className="components-toggle-control__help">
+ { helpLabel }
+ </span>
+ )
+ }
className={ classes }
__nextHasNoMarginBottom
>
diff --git a/packages/components/src/toggle-control/style.scss b/packages/components/src/toggle-control/style.scss
index be7966611f..68733b53a9 100644
--- a/packages/components/src/toggle-control/style.scss
+++ b/packages/components/src/toggle-control/style.scss
@@ -6,6 +6,7 @@
}
}
-.components-base-control__help {
- margin-left: $toggle-width + $grid-unit-10;
+.components-toggle-control__help {
+ display: inline-block;
+ margin-inline-start: $toggle-width + $grid-unit-10;
}
What do folks think?
Works for me :) |
Cool. Let's wait a bit in case anyone else wants to share an opinion, and then we can apply any changes and merge. |
Yes, @ciampo's approach is exactly what we did for CheckboxControl. Sorry I missed this in review 🙇 |
LGTM |
Pushed the suggested 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.
Ideally, markup should not be used for presentational purposes. As I suggested in #63490 (comment) it would be better to remove the added |
Yes, it's not exactly ideal, but it's to avoid having to target an internal classname of a separate component ( |
I reckon we should merge this to fix the visual bug, then explore solutions eliminate the need for additional markup separately. |
Follow-up to #63490.
What?
Fix indentation when help text spans several lines.
Why?
Improves appearance.
Testing Instructions
ToggleControl
with longer help text, e.g. the 'Inner blocks use content width' option on Group blocks.