File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,9 +63,11 @@ class NewsTabContainer extends TabContainer {
6363 }
6464 } ] ,
6565 /**
66- * @member {Boolean} resetActiveIndexOnUnmount=true
66+ * @member {Object} unmountConfigs={activeIndex: null}
6767 */
68- resetActiveIndexOnUnmount : true
68+ unmountConfigs : {
69+ activeIndex : null
70+ }
6971 }
7072}
7173
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import Observable from '../core/Observable.mjs';
66import VdomLifecycle from '../mixin/VdomLifecycle.mjs' ;
77import VDomUpdate from '../manager/VDomUpdate.mjs' ;
88import VNodeUtil from '../util/VNode.mjs' ;
9+ import { isDescriptor } from '../core/ConfigSymbols.mjs' ;
910
1011const
1112 closestController = Symbol . for ( 'closestController' ) ,
@@ -110,6 +111,17 @@ class Abstract extends Base {
110111 * @reactive
111112 */
112113 stateProvider_ : null ,
114+ /**
115+ * A map of config names and values to reset to when the component unmounts.
116+ * @member {Object|null} unmountConfigs_={[isDescriptor]:true,merge:'deep',value:null}
117+ * @example {activeIndex: null, value: ''}
118+ * @reactive
119+ */
120+ unmountConfigs_ : {
121+ [ isDescriptor ] : true ,
122+ merge : 'deep' ,
123+ value : null
124+ } ,
113125 /**
114126 * The custom windowIs (timestamp) this component belongs to
115127 * @member {Number|null} windowId_=null
@@ -229,7 +241,11 @@ class Abstract extends Base {
229241 // upon mount, preventing deadlocks where code awaits a VDOM update that effectively already happened.
230242 VDomUpdate . executeCallbacks ( me . id )
231243 } else { // unmount
232- delete me . _mountedPromise
244+ delete me . _mountedPromise ;
245+
246+ if ( me . unmountConfigs ) {
247+ me . set ( me . unmountConfigs )
248+ }
233249 }
234250 }
235251 }
Original file line number Diff line number Diff line change @@ -95,13 +95,6 @@ class Container extends BaseContainer {
9595 * @member {Boolean} removeInactiveCards=true
9696 */
9797 removeInactiveCards : true ,
98- /**
99- * If true, the activeIndex will be reset to null when the component is unmounted.
100- * This is useful for router-driven tab containers to prevent "phantom mounts"
101- * of the previous state before the router updates the active index.
102- * @member {Boolean} resetActiveIndexOnUnmount=false
103- */
104- resetActiveIndexOnUnmount : false ,
10598 /**
10699 * @member {String|null} tabBarId=null
107100 */
@@ -204,18 +197,6 @@ class Container extends BaseContainer {
204197 }
205198 }
206199
207- /**
208- * @param {Boolean } value
209- * @param {Boolean } oldValue
210- */
211- afterSetMounted ( value , oldValue ) {
212- super . afterSetMounted ( value , oldValue ) ;
213-
214- if ( ! value && this . resetActiveIndexOnUnmount ) {
215- this . activeIndex = null
216- }
217- }
218-
219200 /**
220201 * Adjusts the container's layout and CSS classes when the tab bar position changes.
221202 * This method ensures that the `HeaderToolbar` is docked correctly and that the overall
You can’t perform that action at this time.
0 commit comments