diff --git a/src/components/vue-form-builder.vue b/src/components/vue-form-builder.vue index 750e4bf4c..693e10082 100644 --- a/src/components/vue-form-builder.vue +++ b/src/components/vue-form-builder.vue @@ -388,28 +388,30 @@ - + @@ -588,6 +590,7 @@ export default { } return { + showAddPageValidations: false, openedPages: [0], currentPage: 0, selected: null, @@ -763,7 +766,13 @@ export default { onClick(page) { this.$refs.tabsBar.openPageByIndex(page); }, - checkPageName(value) { + checkPageName(value, force = false) { + if (!force && !this.showAddPageValidations) { + return null; + } + if (!value.trim()) { + return this.$t("The Page Name field is required."); + } const pageNames = this.config .map((config) => config.name) .filter((name) => name !== this.originalPageName); @@ -1136,7 +1145,9 @@ export default { this.updateState(); }, addPage(e) { - if (this.$refs.addPageInput.validator.errorCount) { + this.showAddPageValidations = true; + const error = this.checkPageName(this.addPageName, true); + if (error) { e.preventDefault(); return; } @@ -1151,6 +1162,7 @@ export default { items: [] }); this.addPageName = ""; + this.currentPage = this.config.length - 1; this.updateState(); // open new page diff --git a/tests/e2e/specs/pagesDropdown.spec.js b/tests/e2e/specs/pagesDropdown.spec.js index a7c7241d4..f27c707dc 100644 --- a/tests/e2e/specs/pagesDropdown.spec.js +++ b/tests/e2e/specs/pagesDropdown.spec.js @@ -9,6 +9,7 @@ describe("Page Dropdown", () => { // Define Page 2 cy.get("[data-cy=add-page-name]").clear().type("Page_2"); cy.get("[data-cy=add-page-modal] button.btn").eq(1).click(); + cy.wait(300); cy.get('[data-cy=controls-FormButton]:contains("Page")').drag( "[data-cy=screen-drop-zone]", { position: "bottom" }