Prevent dragging a component #54
Answered
by
optimajet
tuthanhoancanh012
asked this question in
Q&A
Replies: 1 comment 4 replies
-
children: nodeArray
.withInsertRestriction((_, child) => {
return child.model.type === RsWizardStepComponentType
}),
This is because const App = () => {
const [form, setForm] = useState<ComponentStore[]>([
{
key: 'Header',
type: 'RsContainer',
props: {
dragable: {value: false},
},
},
{
key: 'Body',
type: 'RsContainer',
props: {},
},
{
key: 'Footer',
type: 'RsContainer',
props: {},
},
])
const schemaChangeCount = useRef(0)
const getForm = useCallback(() => {
console.info('getForm', JSON.stringify(form))
return JSON.stringify({
version: '1',
form: {
key: 'Screen',
type: 'Screen',
props: {
value: {value: 1},
},
children: form,
},
localization: {},
languages: [
{
code: 'en',
dialect: 'US',
name: 'English',
description: 'American English',
bidi: 'ltr',
},
],
defaultLanguage: 'en-US',
})
}, [form])
const onFormSchemaChange = useCallback((schema: string) => {
const result = JSON.parse(schema) as PersistedForm
if (typeof result.form.children === 'undefined') {
return
}
if (JSON.stringify(result.form.children) !== JSON.stringify(form)) {
console.info('result.form.children', JSON.stringify(result.form.children))
console.info('form', JSON.stringify(form))
// example update neuForm logic
setForm([
{
key: 'Header',
type: 'RsContainer',
props: {
dragable: {
value: false,
}
},
},
])
}
}, [form])
return (
<div className="form-builder-container">
<FormBuilder
view={view}
onFormSchemaChange={onFormSchemaChange}
getForm={getForm}
/>
</div>
)
} |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
sergeythrees
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have some questions. Please help me check them.
I want to prevent dragging a component into a specific container node. Is there a way to do this?
The context is that I have a render form schema with onFormSchemaChange, and I want to implement some logic to update the schema and then render it back to the form. However, there is a problem: when I use setState(newFormSchema), the form updates, but all components inside the form builder unmount and remount, causing a flickering effect in the layout.
Is there any other way to update formSchema without triggering the unmounting of all components inside FormView?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions