survey-creator icon indicating copy to clipboard operation
survey-creator copied to clipboard

Custom properties are breaking the survey editor.

Open Matvey1308 opened this issue 3 years ago • 1 comments

###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

  • browser: Chrome 102
  • browser version: 102
  • surveyjs platform (angular or react or jquery or knockout or vue): React
  • surveyjs version: v1.9.39

Matvey1308 avatar Jul 06 '22 14:07 Matvey1308

@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

andrewtelnov avatar Jul 06 '22 14:07 andrewtelnov