diff --git a/packages/survey-core/src/base.ts b/packages/survey-core/src/base.ts index cc54b1c5fa..c34308312b 100644 --- a/packages/survey-core/src/base.ts +++ b/packages/survey-core/src/base.ts @@ -468,8 +468,8 @@ export class Base { public getProgressInfo(): IProgressInfo { return Base.createProgressInfo(); } - public localeChanged() { } - public locStrsChanged() { + public localeChanged(): void { } + public locStrsChanged(): void { if (!!this.arraysInfo) { for (let key in this.arraysInfo) { let item = this.arraysInfo[key]; diff --git a/packages/survey-core/src/question_radiogroup.ts b/packages/survey-core/src/question_radiogroup.ts index 67c97fe795..845c44e627 100644 --- a/packages/survey-core/src/question_radiogroup.ts +++ b/packages/survey-core/src/question_radiogroup.ts @@ -71,7 +71,7 @@ export class QuestionRadiogroupModel extends QuestionCheckboxBase { if(this.isDefaultV2Theme && !this.isDesignMode) { const clearAction = new Action( { - title: this.clearButtonCaption, + locTitleName: "clearCaption", id: `sv-clr-btn-${this.id}`, action: () => { this.clearValue(true); }, innerCss: this.cssClasses.clearButton, diff --git a/packages/survey-core/src/survey-element.ts b/packages/survey-core/src/survey-element.ts index 69dfd967fb..d23de3961d 100644 --- a/packages/survey-core/src/survey-element.ts +++ b/packages/survey-core/src/survey-element.ts @@ -451,6 +451,7 @@ export class SurveyElement extends SurveyElementCore implements ISurvey public getTitleToolbar(): AdaptiveActionContainer { if (!this.titleToolbarValue) { this.titleToolbarValue = this.createActionContainer(true); + this.titleToolbarValue.locOwner = this; this.titleToolbarValue.containerCss = (this.isPanel ? this.cssClasses.panel.titleBar : this.cssClasses.titleBar) || "sv-action-title-bar"; this.titleToolbarValue.setItems(this.getTitleActions()); } @@ -485,6 +486,12 @@ export class SurveyElement extends SurveyElementCore implements ISurvey } this.setPropertyValue("titleActions", actions); } + public locStrsChanged(): void { + super.locStrsChanged(); + if(!!this.titleToolbarValue) { + this.titleToolbarValue.locStrsChanged(); + } + } public get hasTitleActions(): boolean { return this.getTitleActions().length > 0; } diff --git a/packages/survey-core/tests/question_baseselecttests.ts b/packages/survey-core/tests/question_baseselecttests.ts index 11ea42b51d..1070e4b767 100644 --- a/packages/survey-core/tests/question_baseselecttests.ts +++ b/packages/survey-core/tests/question_baseselecttests.ts @@ -2330,3 +2330,19 @@ QUnit.test("question checkbox add a custom property into choicesByUrl, Bug#8783" assert.deepEqual(q1.toJSON(), { name: "q1", choicesByUrl: { valueName: "name", jsonpath: "newpath" } }, "#2"); Serializer.removeProperty("choicesByUrl", "jsonpath"); }); +QUnit.test("Clear action in locale & survey.locale change, Bug#9113", (assert) => { + const survey = new SurveyModel(); + survey.css =survey.css = { root: "sd-root-modern" }; + survey.fromJSON({ + elements: [{ type: "radiogroup", name: "q1", showClearButton: true }] + }); + const q1 = survey.getQuestionByName("q1"); + assert.equal(q1.isDefaultV2Theme, true, "V2 theme"); + assert.ok(q1.getTitleToolbar()); + assert.equal(q1.titleActions.length, 1, "one action"); + const item = q1.titleActions[0]; + assert.equal(item.locTitle.localizationName, "clearCaption", "locName"); + assert.equal(item.locTitle.locale, "", "locale #1"); + survey.locale = "de"; + assert.equal(item.locTitle.locale, "de", "locale #2"); +});