Skip to content

Commit

Permalink
fix slide selection on config language swap
Browse files Browse the repository at this point in the history
  • Loading branch information
yileifeng authored and dnlnashed committed Oct 17, 2023
1 parent 21d8e99 commit b8c0bbe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
14 changes: 8 additions & 6 deletions src/components/editor/dynamic-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,14 @@ export default class DynamicEditorV extends Vue {
}
saveChanges(): void {
if (
this.$refs.slide !== undefined &&
typeof (this.$refs.slide as ImageEditorV | ChartEditorV).saveChanges === 'function'
) {
(this.$refs.slide as ImageEditorV | ChartEditorV).saveChanges();
}
this.$nextTick(() => {
if (
this.$refs.slide !== undefined &&
typeof (this.$refs.slide as ImageEditorV | ChartEditorV).saveChanges === 'function'
) {
(this.$refs.slide as ImageEditorV | ChartEditorV).saveChanges();
}
});
}
}
</script>
Expand Down
8 changes: 6 additions & 2 deletions src/components/editor/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export default class EditorV extends Vue {
selectSlide(index: number): void {
// save changes to current slide before changing slides
if (this.$refs.slide !== undefined) {
(this.$refs.slide as SlideEditorV).saveChanges();
this.$nextTick(() => {
(this.$refs.slide as SlideEditorV).saveChanges();
});
}
// Quickly swap to loading page, and then swap to new slide. Allows Vue to re-draw page correctly.
Expand Down Expand Up @@ -253,7 +255,9 @@ export default class EditorV extends Vue {
saveChanges(): void {
// save current slide final changes before generating config file
if (this.$refs.slide !== undefined) {
(this.$refs.slide as SlideEditorV).saveChanges();
this.$nextTick(() => {
(this.$refs.slide as SlideEditorV).saveChanges();
});
}
// emit save changes event
Expand Down
6 changes: 5 additions & 1 deletion src/components/editor/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,12 @@ export default class MetadataEditorV extends Vue {
return;
}
this.loadConfig(this.configs[this.configLang]);
if (this.loadEditor) {
(this.$refs.mainEditor as EditorV).selectSlide(-1);
(this.$refs.mainEditor as EditorV).updateSlides(this.slides);
this.$nextTick(() => {
(this.$refs.mainEditor as EditorV).selectSlide(-1);
});
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/components/editor/slide-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,14 @@ export default class SlideEditorV extends Vue {
}
saveChanges(): void {
if (
this.$refs.editor !== undefined &&
typeof (this.$refs.editor as ImageEditorV | ChartEditorV).saveChanges === 'function'
) {
(this.$refs.editor as ImageEditorV | ChartEditorV).saveChanges();
}
this.$nextTick(() => {
if (
this.$refs.editor !== undefined &&
typeof (this.$refs.editor as ImageEditorV | ChartEditorV).saveChanges === 'function'
) {
(this.$refs.editor as ImageEditorV | ChartEditorV).saveChanges();
}
});
}
selectSlide(index: number): void {
Expand Down

0 comments on commit b8c0bbe

Please sign in to comment.