@@ -121,10 +121,12 @@ export default class ModelManager {
121121 this . activeViewName = name ;
122122 this . activeViewIndex = index ;
123123
124- // getPropertyList() will generate our data model.
125- // Afterwards, we run our hooks.
126- this . getPropertyList ( ) ;
127- this . runHooks ( ) ;
124+ if ( name && index >= 0 ) {
125+ // getPropertyList() will generate our data model.
126+ // Afterwards, we run our hooks.
127+ this . getPropertyList ( ) ;
128+ this . runHooks ( ) ;
129+ }
128130 }
129131
130132 // --------
@@ -162,15 +164,25 @@ export default class ModelManager {
162164 deleteView ( viewName , index ) {
163165 this . data [ viewName ] . splice ( index , 1 ) ;
164166
165- if ( this . activeViewName === viewName ) {
167+ // force change view temporarily
168+ // primarily for vue, so vue will update if the active
169+ // viewName and index do not change by the end of this method.
170+ const activeViewName = this . activeViewName ;
171+ const activeViewIndex = this . activeViewIndex ;
172+ this . activateView ( null , - 1 ) ;
173+
174+ if ( activeViewName === viewName ) {
166175 if ( this . data [ viewName ] . length ) {
167- const newIndex = this . activeViewIndex === index ? index - 1 : index ;
168- this . activateView ( viewName , newIndex ) ;
169- } else {
170- this . activateView ( null , - 1 ) ;
176+ if ( activeViewIndex > index ) {
177+ this . activateView ( activeViewName , activeViewIndex - 1 ) ;
178+ } else if ( activeViewIndex === index ) {
179+ this . activateView ( viewName , index ) ;
180+ } else {
181+ this . activateView ( viewName , activeViewIndex ) ;
182+ }
171183 }
172184 } else {
173- this . activateView ( viewName , - 1 ) ;
185+ this . activateView ( activeViewName , activeViewIndex ) ;
174186 }
175187 }
176188
0 commit comments