Skip to content

Commit 302cc22

Browse files
fix(Component Authoring): changes don't update in component preview on blur
1 parent 7070047 commit 302cc22

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

src/assets/wise5/authoringTool/components/component-authoring.component.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,25 @@ export class ComponentAuthoringComponent {
6060
private projectTranslationService: TeacherProjectTranslationService
6161
) {
6262
effect(() => {
63-
// apply translations to a copy of the component content so the original component content
64-
// is not modified for subsequent use.
65-
const componentContent = copy(this.componentContent);
66-
this.projectTranslationService.applyTranslations(
67-
componentContent,
68-
this.projectTranslationService.currentTranslations()
69-
);
70-
this.component = new ComponentFactory().getComponent(
71-
this.projectService.injectAssetPaths(componentContent),
72-
this.nodeId
73-
);
63+
this.setComponent();
7464
});
7565
}
66+
67+
ngOnChanges(): void {
68+
this.setComponent();
69+
}
70+
71+
private setComponent(): void {
72+
// when current translations change, apply translations to a copy of the component content
73+
// so the original component content is not modified for subsequent use.
74+
const componentContent = copy(this.componentContent);
75+
this.projectTranslationService.applyTranslations(
76+
componentContent,
77+
this.projectTranslationService.currentTranslations()
78+
);
79+
this.component = new ComponentFactory().getComponent(
80+
this.projectService.injectAssetPaths(componentContent),
81+
this.nodeId
82+
);
83+
}
7684
}

0 commit comments

Comments
 (0)