From 8bb57aa41d5a4e212ad96dd9bd5d299798b4e60f Mon Sep 17 00:00:00 2001 From: Its-treason <39559178+Its-treason@users.noreply.github.com> Date: Fri, 29 Sep 2023 21:20:36 +0200 Subject: [PATCH] fix: location validation in create collection form --- .../src/components/Sidebar/CreateCollection/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/CreateCollection/index.js b/packages/bruno-app/src/components/Sidebar/CreateCollection/index.js index 8a65bedb2..97e0241e0 100644 --- a/packages/bruno-app/src/components/Sidebar/CreateCollection/index.js +++ b/packages/bruno-app/src/components/Sidebar/CreateCollection/index.js @@ -28,7 +28,9 @@ const CreateCollection = ({ onClose }) => { .min(1, 'must be atleast 1 characters') .max(50, 'must be 50 characters or less') .required('folder name is required'), - collectionLocation: Yup.string().required('location is required') + collectionLocation: Yup.string() + .min(1, 'location is required') + .required('location is required') }), onSubmit: (values) => { dispatch(createCollection(values.collectionName, values.collectionFolderName, values.collectionLocation)) @@ -43,7 +45,10 @@ const CreateCollection = ({ onClose }) => { const browse = () => { dispatch(browseDirectory()) .then((dirPath) => { - formik.setFieldValue('collectionLocation', dirPath); + // When the user closes the diolog without selecting anything dirPath will be false + if (typeof dirPath === 'string') { + formik.setFieldValue('collectionLocation', dirPath); + } }) .catch((error) => { formik.setFieldValue('collectionLocation', '');