Skip to content

Commit 2a888fc

Browse files
authored
When firstPageIsStartPage is enabled, the number of a ghost page on the design surface is incorrect fix #6623 (#6637)
1 parent 91742bb commit 2a888fc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/survey-creator-core/src/components/tabs/designer.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,17 @@ export class TabDesignerViewModel extends Base {
7272
});
7373
}
7474
};
75-
newPage.num = this.survey.pages.length + 1;
75+
newPage.num = this.getNewPageNum();
7676
newPage.onPropertyChanged.add(checkNewElementHandler);
7777
DragDropSurveyElements.newGhostPage = newPage;
7878
delete newPage["ignoreUndoRedo"];
7979
return newPage;
8080
}
81+
private getNewPageNum(): number {
82+
const pages = this.survey.pages;
83+
const num = pages.length + (this.survey.firstPageIsStarted ? 0 : 1);
84+
return num > 0 ? num : 1;
85+
}
8186
private get canShowNewPage(): boolean {
8287
if (!this.survey || this.creator.pageEditMode === "single" || !this.creator.allowModifyPages) return false;
8388
return true;
@@ -265,6 +270,9 @@ export class TabDesignerViewModel extends Base {
265270
}
266271
this.checkNewPage(updatePageController);
267272
}
273+
if(propName === "firstPageIsStartPage") {
274+
this.checkNewPage(true);
275+
}
268276
this.isUpdatingNewPage = false;
269277
}
270278
private calculateDesignerCss() {
@@ -319,7 +327,7 @@ export class TabDesignerViewModel extends Base {
319327
}
320328
if (updatePageController) {
321329
if (this.newPage) {
322-
this.newPage.num = this.survey.pages.length + 1;
330+
this.newPage.num = this.getNewPageNum();
323331
this.newPage.startLoadingFromJson();
324332
this.newPage.name = SurveyHelper.getNewPageName(this.survey.pages);
325333
this.newPage.endLoadingFromJson();

packages/survey-creator-core/tests/tabs/designer.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,14 @@ test("StringEditorViewModelBase page title placeholder for started page", () =>
133133
expect(editor.placeholderValue).toBeUndefined();
134134
expect(editor.placeholder).toBe("Start Page");
135135
expect(editor.placeholderValue).toBe("Start Page");
136+
const desigerTab = creator.getPlugin("designer").model as TabDesignerViewModel;
137+
const adorderPageGhost = new PageAdorner(creator, desigerTab.newPage);
138+
adorderPageGhost.isGhost = true;
139+
const editorGhost: StringEditorViewModelBase = new StringEditorViewModelBase(desigerTab.newPage.locTitle, null);
140+
expect(editorGhost.placeholder).toBe("Page 2");
136141
survey.firstPageIsStartPage = false;
137142
expect(editor.placeholder).toBe("Page 1");
143+
expect(editorGhost.placeholder).toBe("Page 3");
138144
});
139145

140146
test("Logo css", () => {

0 commit comments

Comments
 (0)