From aca20d87bfe9ceb0dc3f9b7d5f76b2a0fa61d8c7 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Mon, 11 Sep 2023 11:31:40 +0300 Subject: [PATCH] Fix showing description on empty survey in designer --- src/panel.ts | 6 +++--- src/survey-element.ts | 2 +- tests/paneltests.ts | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/panel.ts b/src/panel.ts index bd81864e25..e784cda253 100644 --- a/src/panel.ts +++ b/src/panel.ts @@ -322,9 +322,9 @@ export class PanelModelBase extends SurveyElement protected canShowTitle(): boolean { return true; } @property({ defaultValue: true }) showDescription: boolean; get _showDescription(): boolean { - return this.survey && (this.survey).showPageTitles && this.hasDescription && !this.isDesignMode || - (this.showDescription && this.isDesignMode && this.showTitle && - settings.designMode.showEmptyTitles && + if(!this.hasTitle && this.isDesignMode) return false; + return this.survey && (this.survey).showPageTitles && this.hasDescription || + (this.showDescription && this.isDesignMode && settings.designMode.showEmptyDescriptions); } public localeChanged() { diff --git a/src/survey-element.ts b/src/survey-element.ts index 52b45b163e..fb55f4f4ef 100644 --- a/src/survey-element.ts +++ b/src/survey-element.ts @@ -70,7 +70,7 @@ export abstract class SurveyElementCore extends Base implements ILocalizableOwne const property: JsonObjectProperty = Serializer.findProperty(this.getType(), "description"); showPlaceholder = !!(property?.placeholder); } - this.hasDescription = !!newDescription || showPlaceholder; + this.hasDescription = !!newDescription || (showPlaceholder && this.isDesignMode); } get locDescription(): LocalizableString { diff --git a/tests/paneltests.ts b/tests/paneltests.ts index 499732c38a..bd5088d6e6 100644 --- a/tests/paneltests.ts +++ b/tests/paneltests.ts @@ -783,6 +783,10 @@ QUnit.test( page._showDescription, "Entered description is visible in DesignMode" ); + page.title = ""; + page.description = ""; + assert.notOk(page.hasTitle, "No title"); + assert.notOk(page._showDescription, "No description"); } );