Skip to content

Commit 70d2af3

Browse files
Bug/cv2 2000 ghost page has duplicate element (surveyjs#2011)
* fixed surveyjs#2000 * work for the surveyjs#2000
1 parent 864b32e commit 70d2af3

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/survey-creator-core/src/components/page.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ export class PageViewModel<
2727
page["surveyChangedCallback"] = () => {
2828
this.isPageLive = !!page.survey;
2929
};
30-
if(this.isGhost) {
30+
if (this.isGhost) {
3131
this.updateActionsProperties();
3232
this.page.registerFunctionOnPropertiesValueChanged(
3333
["title", "description"],
3434
() => {
3535
this.addGhostPage();
3636
}
3737
);
38+
this.patchPageForDragDrop(this.page, this.addGhostPage);
3839
}
3940
this.page.onFirstRendering();
4041
this.page.updateCustomWidgets();
@@ -48,6 +49,15 @@ export class PageViewModel<
4849
this.onPageSelectedCallback();
4950
}
5051
}
52+
private patchPageForDragDrop(page: PageModel, addGhostPage: () => void) {
53+
// need for the drag drop see https://github.com/surveyjs/survey-library/blob/871492817561de11f934ebdf50481770300a396a/src/dragdrop/survey-elements.ts#L266
54+
page["_isGhost"] = true;
55+
page["_addGhostPageViewModel"] = () => {
56+
delete page["_isGhost"];
57+
delete page["_addGhostPageViewModel"];
58+
addGhostPage();
59+
};
60+
}
5161
public dispose() {
5262
super.dispose();
5363
this.page.unRegisterFunctionOnPropertiesValueChanged([
@@ -66,7 +76,7 @@ export class PageViewModel<
6676
return this._page;
6777
}
6878

69-
public addGhostPage() {
79+
public addGhostPage = () => {
7080
if (this.isGhost) {
7181
this.page.unRegisterFunctionOnPropertiesValueChanged([
7282
"title",

testCafe/designer/drag-drop.ts

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ test("Drag Drop Toolbox Item and Empty Page", async (t) => {
3232

3333
const questionsLength = await getQuestionsLength();
3434
await t.expect(questionsLength).eql(2);
35+
36+
const ghostPageRowsCount = newGhostPagePage.find(".svc-row").count;
37+
await t.expect(ghostPageRowsCount).eql(0);
3538
});
3639

3740
test("Drag Drop Question", async (t) => {

0 commit comments

Comments
 (0)