Skip to content

Commit cc7def1

Browse files
committed
feat: Add resetActiveIndexOnUnmount config to Neo.tab.Container (#8812)
This introduces a generic mechanism to prevent 'phantom mounts' in router-driven TabContainers. By setting this config to true, the activeIndex is automatically reset to null when the component unmounts, ensuring it mounts in a clean state awaiting the Router's instruction. Updated Portal.view.news.TabContainer to use this new config instead of the manual workaround.
1 parent b3d0196 commit cc7def1

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

apps/portal/view/news/TabContainer.mjs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,11 @@ class NewsTabContainer extends TabContainer {
6161
route : '/news/releases',
6262
text : 'Release Notes'
6363
}
64-
}]
65-
}
66-
/**
67-
* @param {Boolean} value
68-
* @param {Boolean} oldValue
69-
*/
70-
afterSetMounted(value, oldValue) {
71-
super.afterSetMounted(value, oldValue);
72-
73-
if (value === false) {
74-
this.activeIndex = null
75-
}
64+
}],
65+
/**
66+
* @member {Boolean} resetActiveIndexOnUnmount=true
67+
*/
68+
resetActiveIndexOnUnmount: true
7669
}
7770
}
7871

src/tab/Container.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ 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,
98105
/**
99106
* @member {String|null} tabBarId=null
100107
*/
@@ -197,6 +204,18 @@ class Container extends BaseContainer {
197204
}
198205
}
199206

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+
200219
/**
201220
* Adjusts the container's layout and CSS classes when the tab bar position changes.
202221
* This method ensures that the `HeaderToolbar` is docked correctly and that the overall

0 commit comments

Comments
 (0)