-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
TextControl: Apply zero margin to input element #60282
Conversation
margin: 0
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. |
Size Change: -45 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
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 generally agree with the change, but wasn't able to see it in effect.
That's likely because we're adding it to the number fields only, and that doesn't affect all the non-number text fields.
I also wonder if this can have any unforeseen consequences. Might require a broader testing of all places that render text control inputs.
From searching the code, it appears that there is no effect. Search Search |
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.
Gave this a round of testing and it actually works well. ✅
Nice work spotting it 👍
🚀
* TextControl: Apply `margin: 0` * Update changelog * Add comment Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
Fixes #59761
What?
This PR applies
margin:0
to theinput
element inside theTextcontrol
component.Why?
As the screenshot in #59761 shows, WP Core applies a 1px margin on both sides of the
input
andselect
elements as a form style. This may make sense on the dashboard, but on aTextControl
component it's an unintended style and causes a 1px misalignment.How?
Applies
margin: 0
to theinput
element inside theTextControl
component.As another approach, I considered applying the margin to the
input-control
mixin itself, but I rejected it for the following reasons:base-styles
package themselves, and it may affect their UI.TextControl
component that is causing this problem. For example, in other components we override the left and right margins with zero as below:gutenberg/packages/components/src/select-control/styles/select-control-styles.ts
Line 132 in 6ebbb8b
gutenberg/packages/components/src/input-control/styles/input-control-styles.tsx
Line 219 in 6ebbb8b
gutenberg/packages/components/src/radio-control/style.scss
Line 10 in 6ebbb8b
Testing Instructions
Screenshots or screencast
Below is an example of a block sidebar.
Before
The 1px margin pushes the component to the right and doesn't line up with other components.
After
It should line up perfectly with the other components.