Skip to content

Commit

Permalink
Fix tab's models are disposed twice in knockout (#5238)
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Feb 22, 2024
1 parent e2e5baa commit 5e811c7
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class TabDesignerPlugin implements ICreatorPlugin {
this.creator.focusElement(undefined, true);
}
public deactivate(): boolean {
if(this.model) {
this.model.dispose();
}
this.model = undefined;
this.propertyGridTab.visible = false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export abstract class TabJsonEditorBasePlugin implements ICreatorPlugin {
this.creator.selectedElement = this.creator.survey;
this.creator.setModified({ type: "JSON_EDITOR" });
}
this.model.dispose();
this.model = undefined;
}
return true;
Expand Down
4 changes: 3 additions & 1 deletion packages/survey-creator-knockout/src/tabs/designer.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<!-- ko if: isToolboxVisible -->
<svc-adaptive-toolbox params="model: creator"></svc-adaptive-toolbox>
<!-- /ko -->
Expand Down Expand Up @@ -65,4 +66,5 @@
<!-- /ko -->
<!-- /ko -->
</div>
</div>
</div>
<!-- /ko -->
2 changes: 1 addition & 1 deletion packages/survey-creator-knockout/src/tabs/designer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ko.components.register("svc-tab-designer", {
const model = <TabDesignerViewModel>params.data.model;
new ImplementorBase(model);
new ImplementorBase(model.pagesController);
return model;
return { model };
}
},
template: template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<div class="svc-creator-tab__content">
<div class="svc-json-editor-tab__content">
<div class="svc-json-editor-tab__ace-editor"></div>
Expand All @@ -6,4 +7,5 @@
<!-- /ko -->
</div>
</div>
</div>
</div>
<!-- /ko -->
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ko.components.register("svc-tab-json-editor-ace", {
const plugin: TabJsonEditorAcePlugin = params.data;
new ImplementorBase(plugin.model);
(<AceJsonEditorModel>plugin.model).init(aceEditor);
return plugin.model;
return { model: plugin.model };
}
},
template: template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<div class="svc-creator-tab__content">
<div class="svc-json-editor-tab__content">
<textarea class="svc-json-editor-tab__content-area"
Expand All @@ -8,4 +9,5 @@
<!-- /ko -->
</div>
</div>
</div>
</div>
<!-- /ko -->
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ko.components.register("svc-tab-json-editor-textarea", {
model.textElement = els[0];
}
}
return model;
return { model };
}
},
template: template
Expand Down
4 changes: 3 additions & 1 deletion packages/survey-creator-knockout/src/tabs/logic.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<div class="svc-creator-tab__content">
<div class="svc-plugin-tab__content svc-logic-tab__content" data-bind="css: { 'svc-logic-tab__empty': !hasItems }">
<!-- ko template: { name: 'survey-content', data: itemsSurvey } -->
Expand All @@ -15,4 +16,5 @@
</div>
<!-- /ko -->
</div>
</div>
</div>
<!-- /ko -->
2 changes: 1 addition & 1 deletion packages/survey-creator-knockout/src/tabs/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ko.components.register("svc-tab-logic", {
const plugin: TabLogicPlugin = params.data;
new ImplementorBase(plugin.model);
new ImplementorBase(plugin.model.addNewButton);
return plugin.model;
return { model: plugin.model };
}
},
template: templateHtml
Expand Down
4 changes: 3 additions & 1 deletion packages/survey-creator-knockout/src/tabs/test.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<div class="svc-creator-tab__content svc-test-tab__content"
data-bind="css: { 'svc-creator-tab__content--with-toolbar' : isPageToolbarVisible }">
<div class="svc-plugin-tab__content">
Expand All @@ -12,4 +13,5 @@
<!-- /ko -->
</div>
<!-- /ko -->
</div>
</div>
<!-- /ko -->
2 changes: 1 addition & 1 deletion packages/survey-creator-knockout/src/tabs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ko.components.register("svc-tab-test", {
const plugin: TabTestPlugin = params.data;
new ImplementorBase(plugin.model.simulator);
new ImplementorBase(plugin.model);
return plugin.model;
return { model: plugin.model };
},
},
template: template
Expand Down
4 changes: 3 additions & 1 deletion packages/survey-creator-knockout/src/tabs/theme.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<div class="svc-creator-tab__content svc-test-tab__content"
data-bind="css: { 'svc-creator-tab__content--with-toolbar' : isPageToolbarVisible }">
<div class="svc-plugin-tab__content">
Expand All @@ -12,4 +13,5 @@
<!-- /ko -->
</div>
<!-- /ko -->
</div>
</div>
<!-- /ko -->
2 changes: 1 addition & 1 deletion packages/survey-creator-knockout/src/tabs/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ko.components.register("svc-tab-theme", {
new ImplementorBase(plugin.model.simulator);
new ImplementorBase(plugin.model.testAgainAction);
new ImplementorBase(plugin.model);
return plugin.model;
return { model: plugin.model };
},
},
template: template
Expand Down
2 changes: 2 additions & 0 deletions packages/survey-creator-knockout/src/tabs/translation.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- ko using: model -->
<div class="svc-creator-tab__content svc-translation-tab">
<div class="st-content">
<!-- ko if: $data.isEmpty -->
Expand All @@ -17,3 +18,4 @@
<!-- /ko -->
</div>
</div>
<!-- /ko -->
2 changes: 1 addition & 1 deletion packages/survey-creator-knockout/src/tabs/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ko.components.register("svc-tab-translation", {
plugin.model.makeObservable((obj: Base) => {
new ImplementorBase(obj);
});
return plugin.model;
return { model: plugin.model };
}
},
template: templateHtml
Expand Down

0 comments on commit 5e811c7

Please sign in to comment.