diff --git a/src/survey.ts b/src/survey.ts index a9edfedde7..283f8d1aa7 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -1023,6 +1023,8 @@ export class SurveyModel extends SurveyElementCore component: "sv-action-bar", data: this.navigationBar }); + + this.locTitle.onStringChanged.add(() => this.titleIsEmpty = this.locTitle.isEmpty); } processClosedPopup(question: IQuestion, popupModel: PopupModel): void { throw new Error("Method not implemented."); @@ -2084,9 +2086,10 @@ export class SurveyModel extends SurveyElementCore return new CssClassBuilder().append(this.css.logo) .append(logoClasses[this.logoPosition]).toString(); } + @property({ defaultValue: true }) private titleIsEmpty: boolean; public get renderedHasTitle(): boolean { if (this.isDesignMode) return this.isPropertyVisible("title"); - return !this.locTitle.isEmpty && this.showTitle; + return !this.titleIsEmpty && this.showTitle; } public get renderedHasDescription(): boolean { if (this.isDesignMode) return this.isPropertyVisible("description"); @@ -6113,6 +6116,7 @@ export class SurveyModel extends SurveyElementCore this.updateRenderBackgroundImage(); this.updateCurrentPage(); this.hasDescription = !!this.description; + this.titleIsEmpty = this.locTitle.isEmpty; this.setCalculatedWidthModeUpdater(); } diff --git a/tests/surveytests.ts b/tests/surveytests.ts index 68307f6503..e3b4e993f9 100644 --- a/tests/surveytests.ts +++ b/tests/surveytests.ts @@ -12428,6 +12428,7 @@ QUnit.test("Survey<=Base propertyValueChanged", function (assert) { var survey = new SurveyModel(json); var counter = 0; + let log = ""; survey.onPropertyValueChangedCallback = ( name: string, oldValue: any, @@ -12436,13 +12437,14 @@ QUnit.test("Survey<=Base propertyValueChanged", function (assert) { arrayChanges: ArrayChanges ) => { counter++; + log += "->" + name; }; assert.equal(counter, 0, "initial"); survey.title = "new"; - assert.equal(counter, 1, "callback called"); + assert.equal(log, "->title", "callback called for title"); }); QUnit.test( @@ -15020,6 +15022,11 @@ QUnit.test("Test survey renderedHasTitle/renderedHasLogo properties", function ( assert ) { var survey = new SurveyModel(); + assert.equal( + survey["titleIsEmpty"], + true, + "titleIsEmpty due to no title" + ); assert.equal( survey.renderedHasHeader, false, @@ -15027,6 +15034,11 @@ QUnit.test("Test survey renderedHasTitle/renderedHasLogo properties", function ( ); assert.equal(survey.renderedHasTitle, false, "There is not title"); survey.title = "title"; + assert.equal( + survey["titleIsEmpty"], + false, + "titleIs not Empty due to title has been set" + ); assert.equal(survey.renderedHasTitle, true, "There is title"); assert.equal(survey.renderedHasHeader, true, "hasHeader, title is visible"); survey.showTitle = false;