diff --git a/src/components/pages/purchase/form/PurchaseRequestForm.tsx b/src/components/pages/purchase/form/PurchaseRequestForm.tsx index 3607d1a1..ef213ebd 100644 --- a/src/components/pages/purchase/form/PurchaseRequestForm.tsx +++ b/src/components/pages/purchase/form/PurchaseRequestForm.tsx @@ -391,7 +391,9 @@ const PurchaseRequestForm = ({ formik.setFieldValue('area_id', (area as OptionType)?.value || 0); // Reset area dependent fields - formik.setFieldValue('location', null); + formik.setFieldTouched('location', false); + formik.setFieldValue('location', undefined); + formik.setFieldTouched('location_id', false); formik.setFieldValue('location_id', 0); setLocationSelectInputValue(''); @@ -590,7 +592,7 @@ const PurchaseRequestForm = ({ ? 'Pilih Area terlebih dahulu' : 'Pilih Lokasi...' } - value={formik.values.location} + value={formik.values.area_id ? formik.values.location : null} onChange={locationChangeHandler} options={locationOptions} onInputChange={setLocationSelectInputValue} @@ -601,6 +603,7 @@ const PurchaseRequestForm = ({ errorMessage={formik.errors.location_id as string} isDisabled={type === 'detail' || !formik.values.area_id} isClearable={type !== 'detail' && !!formik.values.area_id} + key={`location-${formik.values.area_id}`} />