Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radiogroup | Clear button caption remains untranslated if survey.loca… #9117

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/survey-core/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-core/src/question_radiogroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions packages/survey-core/src/survey-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ export class SurveyElement<E = any> extends SurveyElementCore implements ISurvey
public getTitleToolbar(): AdaptiveActionContainer {
if (!this.titleToolbarValue) {
this.titleToolbarValue = <AdaptiveActionContainer>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());
}
Expand Down Expand Up @@ -485,6 +486,12 @@ export class SurveyElement<E = any> 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;
}
Expand Down
16 changes: 16 additions & 0 deletions packages/survey-core/tests/question_baseselecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <QuestionRadiogroupModel>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");
});