Automatically style required
TextFields when they're left empty.
#2129
Labels
Checkout UI Components
This issue is related to the Checkout UI component library
Checkout UI Extensions
enhancement
New feature or request
Please list the related package(s)
checkout-ui-extensions
If this related to specific APIs or components, please list them here
TextField - https://shopify.dev/docs/api/checkout-ui-extensions/2024-04/components/forms/textfield.
Is your feature request related to a problem? Please describe.
I have a TextField which is required. I need someone to enter a value.
I've added the
required
field, but as per the docs:This seems like an odd choice to me - as I now need to write code to determine if the form has been submitted, and then use that to determine whether I need to show the error about it being required or not.
It would be awesome if the TextField (and I assume others) could maintain this state logic themselves - showing an appropriate error message if
required
and not completed on submit.Describe the changes you are looking for
I would love if the TextField could, onSubmit, automatically show an error message because the field is required. I would like it if the message was customisable.
Describe alternatives you’ve considered
I've considered managing state using
onSubmit
to store a value as to whether the form has been submitted, and then using that to determine if an error should be shown.If I don't do this, then the form shows with an error on load because it is empty. I'd prefer if the empty state is only highlighted to the user at the point they submit the form - as until then, there may be a good reason why it's not filled.
Additional context
The text was updated successfully, but these errors were encountered: