survey-creator
survey-creator copied to clipboard
V2: Using `creator.onPageAdded.add` to make an edit to the new page causes the editor to not show another new empty page after
Are you requesting a feature, reporting a bug or ask a question?
Reporting a bug
What is the current behavior?
Have a survey with 1 page, 1 question. The editor shows a second page (empty) so you can drag and drop a question there. After drag drop, a 3rd empty page is added. So you've always got this extra empty page. [Working]
If you use the onPageAdded event, to edit the page after it's added. This new empty page doesn't get added. E.g.
let index = 0;
creator.onPageAdded.add(function(sender, options) {
options.page.title = 'hello world' + index++;
});
What is the expected behavior?
Adding logic via the events shouldn't affect other logic.
How would you reproduce the current behavior (if this is a bug)?
https://plnkr.co/edit/CBoqYRHP2bvMlvyU
- Run plunkr. Comment out the
options.page.title = 'hello world' + index++;line. - Add a question
- Drag this question to page 2
- Now page 3 exists, drag to page 3. This can be repeated forever.
- Reset plunkr.
- Repeat steps 2 - 4 above, you can only move it once, page 3 is not added.
Provide the test code and the tested page URL (if applicable)
Specify your
- browser: Chrome
- editor version: 1.9.40
@benmoses-equineregister If you go to JSON, you will see that there is only two pages. The third page is a ghost page. It is not created yet.
Thank you, Andrew
In the bug scenario I describe. When you move question from page 1 to Ghost page 2. Ghost page 3 is added. Ghost page 2 becomes page 2, and Page 1 continues to exist. [expected behaviour]
bug, if there is an onPageAdded event listener, which edits the new page. Then Ghost Page 3 is not created. Ghost page 2, becomes Page 2. And you cannot drag the question to ghost page 3 because it's not there.
@benmoses-equineregister Yes, the bug is not connected to onPageAdded event. If you add a new question into Page1, you will have a ghost page. After moving into ghost page a question from page1, a new ghost page is not created. I have created a new issue. Regarding your issue. We delete a page if it is a last page, there is no any elements in it and all properties are empty or default. In your case, you set the title to your page and SurveyJS designer thinks that it can not delete this page, because the title is not default and it was modified.
Thank you, Andrew SurveyJS Team If you like our products, please take a moment to share your experience with our company by contributing a short review for SurveyJS page at g2.com or at Trustpilot.com. As we’re building our business, every review helps build credibility for future customers and your feedback would be greatly appreciated.