Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje committed Nov 19, 2024
1 parent 8e8b21b commit b9654c1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
42 changes: 27 additions & 15 deletions superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const Tabs = props => {
tabIndex,
activeKey,
};
}, [activeTabs?.length, props.component, directPathToChild]);
}, [activeTabs, props.component, directPathToChild]);

const [activeKey, setActiveKey] = useState(initActiveKey);
const [selectedTabIndex, setSelectedTabIndex] = useState(initTabIndex);
Expand All @@ -173,14 +173,14 @@ export const Tabs = props => {
} else {
props.setActiveTab(activeKey);
}
}, [activeKey]);
}, [props.setActiveTab, prevActiveKey, activeKey]);

useEffect(() => {
if (prevDashboardId && props.dashboardId !== prevDashboardId) {
setSelectedTabIndex(initTabIndex);
setActiveKey(initActiveKey);
}
}, [props.dashboardId, prevDashboardId]);
}, [props.dashboardId, prevDashboardId, initTabIndex, initActiveKey]);

useEffect(() => {
const maxIndex = Math.max(0, props.component.children.length - 1);
Expand Down Expand Up @@ -224,6 +224,7 @@ export const Tabs = props => {
props.isComponentVisible,
selectedTabIndex,
prevDirectPathToChild,
prevTabIds,
]);

const handleClickTab = useCallback(
Expand Down Expand Up @@ -390,13 +391,19 @@ export const Tabs = props => {

const { children: tabIds } = tabsComponent;

const showDropIndicators = currentDropTabIndex =>
currentDropTabIndex === dragOverTabIndex && {
left: editMode && dropPosition === DROP_LEFT,
right: editMode && dropPosition === DROP_RIGHT,
};
const showDropIndicators = useCallback(
currentDropTabIndex =>
currentDropTabIndex === dragOverTabIndex && {
left: editMode && dropPosition === DROP_LEFT,
right: editMode && dropPosition === DROP_RIGHT,
},
[dragOverTabIndex, dropPosition, editMode],
);

const removeDraggedTab = tabID => draggingTabId === tabID;
const removeDraggedTab = useCallback(
tabID => draggingTabId === tabID,
[draggingTabId],
);

let tabsToHighlight;
const highlightedFilterId =
Expand Down Expand Up @@ -498,24 +505,29 @@ export const Tabs = props => {
</StyledTabsContainer>
),
[
activeKey,
editMode,
renderHoverMenu,
handleDeleteComponent,
handleClickTab,
tabsComponent.id,
activeKey,
handleEdit,
handleDropOnTab,
renderTabContent,
tabIds,
tabsComponent.id,
handleClickTab,
removeDraggedTab,
showDropIndicators,
depth,
availableColumnCount,
columnWidth,
handleDropOnTab,
handleGetDropPosition,
handleDragggingTab,
tabsToHighlight,
renderTabContent,
onResizeStart,
onResize,
onResizeStop,
selectedTabIndex,
isCurrentTabVisible,
tabsToHighlight,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { useCallback, memo, useMemo } from 'react';
import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { isDefined } from '@superset-ui/core';
import { useSelector, useDispatch } from 'react-redux';
import { logEvent } from 'src/logger/actions';
import { addDangerToast } from 'src/components/MessageToasts/actions';
Expand Down Expand Up @@ -123,6 +124,9 @@ const DashboardComponent = props => {
fullSizeChartId={fullSizeChartId}
occupiedColumnCount={occupiedColumnCount}
minColumnWidth={minColumnWidth}
isComponentVisible={
isDefined(props.isComponentVisible) ? props.isComponentVisible : true
}
{...boundActionCreators}
{...props}
/>
Expand Down

0 comments on commit b9654c1

Please sign in to comment.