Skip to content

Commit 8158a9f

Browse files
committed
fix(ModelManager): Run view hooks on view delete
Update bundled hooks to verify viewData existence before use.
1 parent e234dac commit 8158a9f

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/core/ModelManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ export default class ModelManager {
206206
}
207207
} else {
208208
this.activateView(activeViewName, activeViewIndex);
209+
// run deleted view hooks
210+
this.runHooks(viewName, index);
209211
}
210212
}
211213

src/hooks/copy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/* eslint-disable no-param-reassign */
22

33
export default function copy(hookConfig, dataModel, currentViewData) {
4+
if (!currentViewData) {
5+
return;
6+
}
7+
48
const { src, dst } = hookConfig;
59
let value = dataModel;
610
const [attributeName, parameterId] = dst.split('.');

src/hooks/copyParameterToViewName.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export default function copyParameterToViewName(
55
dataModel,
66
currentViewData
77
) {
8+
if (!currentViewData) {
9+
return;
10+
}
11+
812
const [attributeName, parameterId] = hookConfig.attribute.split('.');
913
if (
1014
currentViewData[attributeName] &&

src/hooks/copyViewNameToAttributeParameter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export default function copyViewNameToAttributeParameter(
55
fullDataModel,
66
localViewDataModel
77
) {
8+
if (!localViewDataModel) {
9+
return;
10+
}
11+
812
const name = localViewDataModel.name;
913
const [attributeName, parameterId] = hookConfiguration.attribute.split('.');
1014
localViewDataModel[attributeName][parameterId].value = [name];

0 commit comments

Comments
 (0)