diff --git a/src/components/@shared/FormFields/FilesInput/index.tsx b/src/components/@shared/FormFields/FilesInput/index.tsx index 527fb1f38..bc903c03c 100644 --- a/src/components/@shared/FormFields/FilesInput/index.tsx +++ b/src/components/@shared/FormFields/FilesInput/index.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, useState } from 'react' +import React, { ReactElement, useEffect, useState } from 'react' import { useField, useFormikContext } from 'formik' import FileInfo from './Info' import UrlInput from '../URLInput' @@ -16,7 +16,7 @@ export default function FilesInput(props: InputProps): ReactElement { async function handleValidation(e: React.SyntheticEvent, url: string) { // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() + e?.preventDefault() try { const providerUrl = values?.services @@ -47,6 +47,12 @@ export default function FilesInput(props: InputProps): ReactElement { helpers.setTouched(false) } + useEffect(() => { + if (field.name === 'links' && asset?.metadata?.links) { + handleValidation(null, asset.metadata.links[0]) + } + }, []) + return ( <> {field?.value?.[0]?.valid === true ? (