From 0943e340a659ca47951d780952390b5a85dc0a1a Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Mon, 11 Dec 2023 16:21:53 +0200 Subject: [PATCH] Specialized Components - A Text question's placeholder is not updated when changing a survey's locale fix #7480 --- src/question_custom.ts | 10 ++++++++-- tests/question_customtests.ts | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/question_custom.ts b/src/question_custom.ts index 7948ae6684..09575844c6 100644 --- a/src/question_custom.ts +++ b/src/question_custom.ts @@ -414,8 +414,14 @@ export abstract class QuestionCustomModelBase extends Question this.getElement().locStrsChanged(); } } - protected createWrapper() { } - protected onPropertyValueChanged(name: string, oldValue: any, newValue: any) { + public localeChanged(): void { + super.locStrsChanged(); + if(!!this.getElement()) { + this.getElement().localeChanged(); + } + } + protected createWrapper(): void { } + protected onPropertyValueChanged(name: string, oldValue: any, newValue: any): void { super.onPropertyValueChanged(name, oldValue, newValue); if (!!this.customQuestion && !this.isLoadingFromJson) { this.customQuestion.onPropertyChanged(this, name, newValue); diff --git a/tests/question_customtests.ts b/tests/question_customtests.ts index a26bef7fc6..039c45cb4c 100644 --- a/tests/question_customtests.ts +++ b/tests/question_customtests.ts @@ -2545,3 +2545,23 @@ QUnit.test("Allow to add question via addNewQuestion for component, but not for assert.notOk(q3, "matrixdropdownbase is not created"); ComponentCollection.Instance.clear(); }); +QUnit.test("text placeholder is not updated on changing locale", function (assert) { + ComponentCollection.Instance.add({ + name: "customtext", + questionJSON: { + type: "text", + placeholder: { en: "en-TextPH", de: "de-TextPH" }, + }, + }); + const survey = new SurveyModel({ + elements: [ + { type: "customtext", name: "q1" } + ] + }); + const q1 = survey.getQuestionByName("q1"); + const contentQuestion = q1.contentQuestion; + assert.equal(contentQuestion.renderedPlaceholder, "en-TextPH", "en placeholder"); + survey.locale = "de"; + assert.equal(contentQuestion.renderedPlaceholder, "de-TextPH", "de placeholder"); + ComponentCollection.Instance.clear(); +});