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

Function onModified is called to often

Open Akkora opened this issue 2 years ago • 1 comments

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

Bug

What is the current behavior?

The function onModified is called to often. In the example it is called

  • three times when first adding a question
  • two times when adding another question
  • two times when removing a question
  • and once (how it should be) when changing a question

What is the expected behavior?

The onModified function should be called once per change

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

Add onModified function and check how often it is called.

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

Tested page URL: https://plnkr.co/edit/iQ2dcF7yC1Q52sK7

Specify your

  • browser: Chrome 98
  • editor version: 1.9.18

Akkora avatar Mar 07 '22 09:03 Akkora

If you look at onModified event documentation - https://surveyjs.io/Documentation/Survey-Creator?id=surveycreator#onModified you will see that there is an options parameter and events could be filtered by type.

I modified your example: https://plnkr.co/edit/FGurjjgZ5zJImOpZ

There you can notice thai when you add a question to empty creator page there is three events with the different types:

modified 1 {type: 'PAGE_ADDED', newValue: t}
modified 2 {type: 'ADDED_FROM_TOOLBOX', question: t}
modified 3 {type: 'PROPERTY_CHANGED', name: 'pages', target: t, oldValue: Array(0), newValue: Array(1)}

First event says about added page. Second - about adding new question. Third is the common event fired on every property change. Property pages is changing when page added.

novikov82 avatar Apr 07 '22 14:04 novikov82