Skip to content

Commit

Permalink
Page title and description placeholders and question adorner texts ar… (
Browse files Browse the repository at this point in the history
#6444)

* Page title and description placeholders and question adorner texts are not updated when changing a creator.locale at runtime fix #6441

* Fix functional test
  • Loading branch information
andrewtelnov committed Jan 27, 2025
1 parent d62b398 commit 795a7f2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
20 changes: 20 additions & 0 deletions functionalTests/designer/localization_dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { url, setJSON } from "../helper";
import { ClientFunction, Selector } from "testcafe";
const title = "Localization UI";

const changeLocale = ClientFunction(() => {
window["creator"].locale = "de";
});

fixture(title)
.page(url)
.beforeEach(async (t) => {
await t.maximizeWindow();
});

test("Change Creator.locale property", async (t) => {
await setJSON({ elements: [{ type: "checkbox", name: "question1" }] });
await t.click(Selector("[data-name='question1']"));
await changeLocale();
await t.expect(Selector(".svc-survey-element-toolbar-item__title--with-icon").withText("Auswahl").exists).ok();
});
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ export class SurveyElementAdornerBase<T extends SurveyElement = SurveyElement> e
this.createActionContainers();
this.attachToUI(surveyElement);
}

private creatorOnLocaleChanged: (sender: Base, options: any) => void = (_, options) => {
if(this.surveyElement) {
this.updateActionsContainer(this.surveyElement);
this.updateActionsProperties();
}
};
public static GetAdorner<V = SurveyElementAdornerBase>(surveyElement: SurveyElement): V {
return surveyElement.getPropertyValue(SurveyElementAdornerBase.AdornerValueName) as V;
}
Expand Down Expand Up @@ -349,6 +354,7 @@ export class SurveyElementAdornerBase<T extends SurveyElement = SurveyElement> e
}
if (this.surveyElement != surveyElement) {
this.setSurveyElement(surveyElement);
this.creator.onLocaleChanded.add(this.creatorOnLocaleChanged);
this.creator.sidebar.onPropertyChanged.add(this.sidebarFlyoutModeChangedFunc);
this.creator.expandCollapseManager.add(this);
}
Expand All @@ -362,6 +368,7 @@ export class SurveyElementAdornerBase<T extends SurveyElement = SurveyElement> e
this.rootElement = undefined;
this.detachOnlyMyElement();
this.surveyElement = undefined;
this.creator.onLocaleChanded.remove(this.creatorOnLocaleChanged);
this.creator.sidebar.onPropertyChanged.remove(this.sidebarFlyoutModeChangedFunc);
this.creator.expandCollapseManager.remove(this);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,9 @@ export class SurveyCreatorModel extends Base
editorLocalization.currentLocale = value;
this.setPropertyValue("locale", value);
this.updateLocalizedStrings();
this.onLocaleChanded.fire(this, { locale: value });
}
public onLocaleChanded: EventBase<SurveyCreatorModel, any> = this.addCreatorEvent<SurveyCreatorModel, any>();
public updateLocalizedStrings(): void {
this.toolbox.updateTitles();
this.refreshPlugin();
Expand Down

0 comments on commit 795a7f2

Please sign in to comment.