Skip to content

Commit 0c82021

Browse files
committed
fix(ModelManager): Activate default view, run hooks on activate
Replace manual viewId increment with built-in getNextViewId().
1 parent de4b555 commit 0c82021

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/core/ModelManager.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export default class ModelManager {
4747
this.activeViewIndex = 0;
4848
this.collapseState = {};
4949
this.listeners = [];
50-
this.nextViewId = 0;
50+
51+
if (this.model.defaultActiveView) {
52+
this.activateView(this.model.defaultActiveView, 0);
53+
}
5154
}
5255

5356
get data() {
@@ -117,6 +120,11 @@ export default class ModelManager {
117120
activateView(name, index = 0) {
118121
this.activeViewName = name;
119122
this.activeViewIndex = index;
123+
124+
// getPropertyList() will generate our data model.
125+
// Afterwards, we run our hooks.
126+
this.getPropertyList();
127+
this.runHooks();
120128
}
121129

122130
// --------
@@ -140,7 +148,7 @@ export default class ModelManager {
140148
const index = viewList.length;
141149
const name = `${this.localizedData.getView(viewName)} ${index}`;
142150

143-
viewList.push({ name, id: this.nextViewId++ });
151+
viewList.push({ name, id: this.getNextViewId() });
144152
this.data = assignObjKey(this.data, viewName, viewList);
145153
this.activateView(viewName, index);
146154
// generate data model for new view (...using a get method with side-effects...)

0 commit comments

Comments
 (0)