Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When firstPageIsStartPage is enabled, the number of a ghost page on t… #6637

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/survey-creator-core/src/components/tabs/designer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,17 @@ export class TabDesignerViewModel extends Base {
});
}
};
newPage.num = this.survey.pages.length + 1;
newPage.num = this.getNewPageNum();
newPage.onPropertyChanged.add(checkNewElementHandler);
DragDropSurveyElements.newGhostPage = newPage;
delete newPage["ignoreUndoRedo"];
return newPage;
}
private getNewPageNum(): number {
const pages = this.survey.pages;
const num = pages.length + (this.survey.firstPageIsStarted ? 0 : 1);
return num > 0 ? num : 1;
}
private get canShowNewPage(): boolean {
if (!this.survey || this.creator.pageEditMode === "single" || !this.creator.allowModifyPages) return false;
return true;
Expand Down Expand Up @@ -265,6 +270,9 @@ export class TabDesignerViewModel extends Base {
}
this.checkNewPage(updatePageController);
}
if(propName === "firstPageIsStartPage") {
this.checkNewPage(true);
}
this.isUpdatingNewPage = false;
}
private calculateDesignerCss() {
Expand Down Expand Up @@ -319,7 +327,7 @@ export class TabDesignerViewModel extends Base {
}
if (updatePageController) {
if (this.newPage) {
this.newPage.num = this.survey.pages.length + 1;
this.newPage.num = this.getNewPageNum();
this.newPage.startLoadingFromJson();
this.newPage.name = SurveyHelper.getNewPageName(this.survey.pages);
this.newPage.endLoadingFromJson();
Expand Down
6 changes: 6 additions & 0 deletions packages/survey-creator-core/tests/tabs/designer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,14 @@ test("StringEditorViewModelBase page title placeholder for started page", () =>
expect(editor.placeholderValue).toBeUndefined();
expect(editor.placeholder).toBe("Start Page");
expect(editor.placeholderValue).toBe("Start Page");
const desigerTab = creator.getPlugin("designer").model as TabDesignerViewModel;
const adorderPageGhost = new PageAdorner(creator, desigerTab.newPage);
adorderPageGhost.isGhost = true;
const editorGhost: StringEditorViewModelBase = new StringEditorViewModelBase(desigerTab.newPage.locTitle, null);
expect(editorGhost.placeholder).toBe("Page 2");
survey.firstPageIsStartPage = false;
expect(editor.placeholder).toBe("Page 1");
expect(editorGhost.placeholder).toBe("Page 3");
});

test("Logo css", () => {
Expand Down