-
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
InputControl: Allow inline styles to be applied to wrapper instead of inner input #45340
InputControl: Allow inline styles to be applied to wrapper instead of inner input #45340
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
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.
The change makes sense to me, but it has the potential of introducing regressions for usages of InputControl
/ NumberControl
/ UnitControl
etc.. that were relying on the style
prop — we should probably take a close look at that to ensure that there are no regressions.
Curious to hear @mirka 's thoughts on this one too
For what it's worth, we can remove The changes in #45139 meant a unit control's The potential regressions for Could a compromise be to introduce a new prop that UnitControl can leverage to fix the regression caused by #45139? |
In my opinion, for the same reason we expect I'm only careful about the potential repercussions of this change (which is why I suggested we took a closer look at how inline styles are passed to |
In terms of regressions, Doing a quick scan of our codebase, I don't see a lot of instances of My preference will be to fix the app-side code so it doesn't rely on I definitely do not want |
I think I agree with a few different points that don't necessarily contradict each other:
|
So I guess my suggested approach is two-fold:
The latter is just my opinion on what I think is the sustainable approach, but if y'all think it's worth making an exception in certain places, I won't block it 😄 |
Great discussion here, and thank you for digging into a fix @aaronrobertshaw!
Same, and I agree with the points above that it'd be good to update usages within Gutenberg to avoid the inline styles. Though @mirka makes a very good point about the expected API. I suppose a challenge from my perspective is that I'm used to the idea of importing relatively simple components where things like If support for passing |
Thank you for the discussion, thoughts, and concerns, everyone 🙇
Those two are for the native component for There is one other case, the
Thanks, I was a little paranoid about missing cases so searched only for uses of There are a couple of edge cases here;
Personally, I don't feel either of those are big issues.
That's the question we need consensus on. Do we restore style going to the wrapper (typing via At this stage, I'm happy to go either way. |
This to me seems the easier change, with the lower impact (basically the |
I'm fine with this too 👍 |
25e378c
to
3c8d736
Compare
This PR has been updated now to leverage It should be right for a final review now unless I've missed something. |
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.
LGTM 🚀
Code changes look good, and the style
prop works as it was agreed
Flagged it for a mention in a 'Component' changes Dev Note
I'd rather err on the side of caution. |
Related:
What?
Why?
When #45139 removed the outer wrapper it allowed inline styles to be passed to the inner input rather than the InputControl's outer wrapper.
Applying them to the outer wrapper appears to be the expected behaviour. A number of blocks control's were just updated to remove passing of inline styles to restrict the control's outer width (#45329).
It also turns out the block gap control passes a CSS grid style to achieve it's layout. This won't work without this fix.
How?
Destructure the inline style prop for the
InputBase
component and pass it to the wrapper instead of the input via the rest props.Testing Instructions
Screenshots or screencast
✍️ Dev Note
In order to improve consistency across the
@wordpress/components
package, any inline styles passed to theInputControl
component through itsstyle
prop will be applied to its outer wrapper element, instead of an inner input wrapper element.These changes may also affect usages of other components relying on
InputControl
, such asNumberControl
andUnitControl
.