Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importScript Error while Drag and Drap New Text field #537

Open
DivyarajsinhRana opened this issue Oct 6, 2023 · 7 comments
Open

importScript Error while Drag and Drap New Text field #537

DivyarajsinhRana opened this issue Oct 6, 2023 · 7 comments

Comments

@DivyarajsinhRana
Copy link

Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cdn.form.io/ace/1.4.12/worker-json.js' failed to load.

Component

import React, { FC, useEffect, useState } from 'react'
import styles from './createNewFormBuilder.module.scss'
import { useLocation, useNavigate } from 'react-router-dom'
import { useAppDispatch, useAppSelector } from '../../../hooks'
import { requestGenerator } from '../../../utils/payloadGenerator'
import CreatedUsersPopup from '../../../components/common/created-users-popup/CreatedUsersPopup'
import { utcToDate } from '../../../utils/utils'
import Button from '../../../components/common/button/Button'
import {
DropDownIcon,
PolygonIcon,
} from '../../../components/common/svg-components'
import { FormBuilder, Form } from 'react-formio/lib/components'
import {
createNewForm,
updateCreateNewFormById,
} from '../../../redux/features/create-new-form/createNewFormAsynActions'

interface ICreateNewFormBuilder {}

const CreateNewFormBuilder: FC = () => {
/* Dependency to navigate between pages /
const navigate = useNavigate()
/
Dependency to navigate between pages */

/* Dependency to dispatch an action /
const dispatch = useAppDispatch()
/
Dependency to dispatch an action */

/* Dependency for form builder /
var selFormBuilderObj = {} // using a state variable and setting in handleFormBuilderChange was causing infinite loop issues so i have used var
const [formBuilderJson, setFormBuilderJson] = useState({
display: 'form',
components: [],
})
/
Dependency for form builder */

/* Selector to get the initial data of module from redux store*/
const {
isLoading,
createNewFormData,
createFormBuilderHeaderData,
isStatusUpdated,
} = useAppSelector((state) => state.createNewForm)
/* Selector to get the initial data of module from redux store*/

useEffect(() => {
/* Navigate back to list component if the following dependencies are not present /
if (
!createFormBuilderHeaderData.name ||
!createFormBuilderHeaderData.module_name ||
!createFormBuilderHeaderData.department_id
) {
navigate('/formBuilder')
}
/
Navigate back to list component if the following dependencies are not present */

if (
  createFormBuilderHeaderData.form &&
  createFormBuilderHeaderData.form !== '' &&
  createFormBuilderHeaderData.form !== null &&
  createFormBuilderHeaderData.form !== undefined
) {
  setFormBuilderJson(JSON.parse(createFormBuilderHeaderData.form))
}

}, [])

/* Function definition for form submission */
const onSubmit = () => {
if (
createFormBuilderHeaderData._id &&
createFormBuilderHeaderData._id !== '' &&
createFormBuilderHeaderData._id !== undefined &&
createFormBuilderHeaderData._id !== null
) {
const dataToBeSent = {
id: createFormBuilderHeaderData._id,
data: {
name: createFormBuilderHeaderData.name,
module_name: createFormBuilderHeaderData.module_name,
department_id: createFormBuilderHeaderData.department_id.value,
note: createFormBuilderHeaderData.note,
form: JSON.stringify({ ...selFormBuilderObj }),
},
}

  // console.log(dataToBeSent, 'datatobesent during update form builder call')
  dispatch(updateCreateNewFormById(requestGenerator(dataToBeSent))).then(
    (result) => {
      navigate('/formBuilder')
    }
  )
} else {
  const dataToBeSent = {
    name: createFormBuilderHeaderData.name,
    module_name: createFormBuilderHeaderData.module_name,
    department_id: createFormBuilderHeaderData.department_id.value,
    note: createFormBuilderHeaderData.note,
    form: JSON.stringify({ ...selFormBuilderObj }),
  }
  dispatch(createNewForm(requestGenerator(dataToBeSent))).then((result) => {
    console.log(result, 'result')
    navigate('/formBuilder')
  })
}

}
/* Function definition for form submission */

/* Function definition for form builder - OnChange /
const handleFormBuilderChange = (schema: any) => {
console.log('schema', schema)
selFormBuilderObj = schema
}
/
Function definition for form builder - OnChange */

return (
<>





Form


{createFormBuilderHeaderData?.name}



Module


{createFormBuilderHeaderData?.module_name}



Department


{createFormBuilderHeaderData?.department_id?.label}









</>
)
}

export default CreateNewFormBuilder

@Shail-Shah-Arche
Copy link

Thanks for sharing this issue.
I am facing the same.

@suman313
Copy link

suman313 commented Oct 8, 2023

Is anyone working in this issue?
If not please assign me this job.
I can work on solving this issue.

@brendanbond
Copy link
Contributor

Is anyone working in this issue?

If not please assign me this job.

I can work on solving this issue.

PRs welcome!

@DivyarajsinhRana
Copy link
Author

Yes sure @suman313 If you can resolve the issue.
Thanks.

@suman313
Copy link

Hi @DivyarajsinhRana ,
Are you facing this issue while using their own platform?
Seems like this component is present in the codebase in which formio has built its platform.
In that case, as a contributor I can only make you aware of the issue but not solve it.
Thanks in advance.

@DivyarajsinhRana
Copy link
Author

Hi @suman313 ,
I Have installed library using npm and created component for form builder as above provided code , while i am drag and drop form elements randomly above error occurs.
"react-formio": "^4.3.0" this is the version which i have installed.
image_2023_10_11T07_09_25_229Z

@PadgetPII
Copy link

@brendanbond @suman313
I am facing the same issue as @DivyarajsinhRana and I was wondering if this issue could be related to this one :
formio/formio.js#5272

It does not happen all the time. I can put 5 text fields on the form, and the 6th is causing that issue.
Which to me feels like the CDN is not responding correctly all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants