EnxDev commented on code in PR #44345:
URL: https://github.com/apache/superset/pull/44345#discussion_r4063788572
##########
superset-frontend/src/dashboard/components/gridComponents/Tabs/Tabs.tsx:
##########
@@ -166,6 +166,25 @@ const Tabs = (props: TabsProps): ReactElement => {
const prevTabIds = usePrevious(props.component.children);
useEffect(() => {
+ // `activeKey` is seeded from state once, so a container that mounted
+ // without children keeps an unresolved key even after it receives its
+ // first one. Resolve it here so the new tab is selected and registered
+ // rather than being skipped by the guard below.
+ const tabId = props.component.children[selectedTabIndex];
+ if (!activeKey && tabId) {
Review Comment:
Thanks, you're right. The deleted tab leaves a truthy `activeKey`, so the
original check misses that case. I've switched to your `includes` check in
a66a3a422e, keeping the `tabId` guard so an empty container still doesn't
register a tab.
I also added a regression test that deletes the last tab and adds a
replacement, checking that it's selected and registered with the deleted tab as
the previous key. It fails before the fix and passes with it. All 31 dashboard
test suites pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]