Fixed validation error: Corrected fields should revert back from erro… (#19374)

Fixes
[PROD-272](https://linear.app/tryghost/issue/PROD-272/corrected-fields-should-revert-back-from-error-state)
This commit is contained in:
Princi Vershwal 2023-12-14 11:02:50 +05:30 committed by GitHub
parent 275cdd4db9
commit 7b0ec35a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,10 +138,13 @@ const Sidebar: React.FC<{
onKeyDown={() => clearError('name')}
/>
<TextField
error={Boolean(errors.displayTitle)}
hint={errors.displayTitle}
placeholder='Black Friday Special'
title='Display title'
value={offer?.display_title}
onChange={e => updateOffer({display_title: e.target.value})}
onKeyDown={() => clearError('displayTitle')}
/>
<TextArea
placeholder='Take advantage of this limited-time offer.'
@ -156,7 +159,7 @@ const Sidebar: React.FC<{
title='Offer code'
value={offer?.code}
onChange={e => updateOffer({code: e.target.value})}
onKeyDown={() => clearError('name')}
onKeyDown={() => clearError('code')}
/>
</div>
</section>
@ -201,6 +204,10 @@ const EditOfferModal: React.FC<{id: string}> = ({id}) => {
newErrors.name = 'Please enter a name';
}
if (!formState?.display_title) {
newErrors.displayTitle = 'Display title is required';
}
if (!formState?.code) {
newErrors.code = 'Please enter a code';
}