From 83ddd475874b1e367992dd7edaf80e9cdfe4d9c1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 5 Jun 2024 12:21:18 +0300 Subject: [PATCH] Knockout: Text for carry forward choices are not changed immediately on changing survey locale fix #8367 (#8368) --- src/question_baseselect.ts | 3 +++ tests/question_baseselecttests.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/question_baseselect.ts b/src/question_baseselect.ts index 9f9d9a7d50..079ad247ef 100644 --- a/src/question_baseselect.ts +++ b/src/question_baseselect.ts @@ -151,6 +151,9 @@ export class QuestionSelectBase extends Question { ItemValue.locStrsChanged(this.choicesFromUrl); ItemValue.locStrsChanged(this.visibleChoices); } + if(this.isUsingCarryForward) { + ItemValue.locStrsChanged(this.visibleChoices); + } } public get otherValue(): string { if(!this.showCommentArea) return this.comment; diff --git a/tests/question_baseselecttests.ts b/tests/question_baseselecttests.ts index f133fd55d7..9e0cfb2905 100644 --- a/tests/question_baseselecttests.ts +++ b/tests/question_baseselecttests.ts @@ -1276,6 +1276,12 @@ QUnit.test("Carry Forward and localization, bug#6352", function (assert) { assert.equal(q2.visibleChoices.length, 1); assert.deepEqual(q2.visibleChoices[0].locText.getJson(), { default: "A de", en: "A en" }); assert.equal(q2.visibleChoices[0].text, "A en"); + let counter = 0; + q2.visibleChoices[0].locText.onStringChanged.add((sender, options) => { + counter ++; + }); + survey.locale = "de"; + assert.equal(counter, 1, "Fire str changed"); surveyLocalization.defaultLocale = "en"; }); QUnit.test("Carry Forward and keepIncorrectValues, bug#6490", function (assert) {