[Enhancement]: Form component input props should allow passing of custom callbacks #34996
Labels
focus: components
Issues related to @woocommerce/* packages
type: enhancement
The issue is a request for an enhancement.
Describe the solution you'd like
For the
Form
componentgetInputProps
, we occasionally have to override an event likeonBlur
.The problem is that this overrides the default
getInputProps
onBlur
method and now manually needs to be called:To make things a bit easier on consumers, we could consider an optional second argument that adds props to the event without overriding the
Form
's handlers. E.g.,Describe alternatives you've considered
Manually calling the input form's handler is the current way of handling this, but it is more prone to errors and more cumbersome to write.
getInputProps( 'field_name' ).onBlur();
Additional context
The new product management experience has been creating utils like
getTextControlProps
andgetInputControlProps
that handle specific items like classes. It would be good to move some of this logic back to theForm
package.The text was updated successfully, but these errors were encountered: