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
…e not updated when changing a creator.locale at runtime fix #6441
  • Loading branch information
andrewtelnov committed Jan 24, 2025
1 parent 0ed1cdd commit 2d914dd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
17 changes: 17 additions & 0 deletions functionalTests/designer/localization_dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { url, setJSON, setSurveyProp } from "../helper";
import { ClientFunction, Selector } from "testcafe";
const title = "Localization UI";
const customLogicTabName = "Miner Logik";

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 setSurveyProp("locale", "de");
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 @@ -305,7 +305,11 @@ 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);
}
};
public static GetAdorner<V = SurveyElementAdornerBase>(surveyElement: SurveyElement): V {
return surveyElement.getPropertyValue(SurveyElementAdornerBase.AdornerValueName) as V;
}
Expand Down Expand Up @@ -364,6 +368,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 @@ -377,6 +382,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 @@ -1330,7 +1330,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 2d914dd

Please sign in to comment.