surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
923 stars 377 forks source link

Custom properties are breaking the survey editor. #3248

Closed Matvey1308 closed 9 months ago

Matvey1308 commented 2 years ago

Are you requesting a feature, reporting a bug or asking a question?

Bug

What is the current behavior?

Custom properties. Survey creator React. Custom properties are breaking the survey editor.

I added a custom property with name 'id'. These ids I get from the backend and push them to the survey, pages, questions, etc.

There are two possible variants of this bug:

  1. The name of the property is name: 'id:number', category: 'Backend'. I'm getting Warning: Encountered two children with the same key,NaN-0. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.. All the entities: survey, pages, questions get an id: 'sq_xxx', from our backend we should get just number '123'. Backend property tab -> Id input is empty, but it should contain an id from backend.
  2. The name of the property is name: 'backendId:number', category: 'Backend'. There are no warnings and errors. All ids disappear at all. Property tab 'Backend' is also disappear after any entity was clicked.

What is the expected behavior?

Each entity in survey: pages, questions - should get its own 'id' from our backend. As it was working on survey creator v1.

How would you reproduce the current behavior (if this is a bug)?

Test page URL: https://codesandbox.io/s/tender-star-5nz8sv?file=/src/index.tsx

JSON is what we get after survey saved.

  1. Open test link.
  2. Consider line 12.
  3. Add new questions.
  4. Check the console for the warnings.
  5. Change the line 12 from 'id' to 'backendId'.
  6. Check JSON editor.
  7. Check questions ids.

Provide the test code and the tested page URL (if applicable)

Test page URL: https://codesandbox.io/s/tender-star-5nz8sv?file=/src/index.tsx

Specify your

andrewtelnov commented 2 years ago

@Matvey1308 Please do not use id as a name for the custom property. We have an "id" property in a survey element.

Thank you, Andrew SurveyJS Team