diff --git a/app/client/src/components/propertyControls/TabControl.tsx b/app/client/src/components/propertyControls/TabControl.tsx index 560592f58f..e0835cdfd7 100644 --- a/app/client/src/components/propertyControls/TabControl.tsx +++ b/app/client/src/components/propertyControls/TabControl.tsx @@ -2,9 +2,8 @@ import React from "react"; import BaseControl, { ControlProps } from "./BaseControl"; import { StyledPropertyPaneButton } from "./StyledControls"; import styled from "constants/DefaultTheme"; -import { generateReactKey } from "utils/generators"; import { DroppableComponent } from "components/ads/DraggableListComponent"; -import { getNextEntityName, noop } from "utils/AppsmithUtils"; +import { noop } from "utils/AppsmithUtils"; import orderBy from "lodash/orderBy"; import isString from "lodash/isString"; import isUndefined from "lodash/isUndefined"; @@ -222,28 +221,6 @@ class TabControl extends BaseControl { ); }; - addOption = () => { - let tabs = this.props.propertyValue; - const tabsArray = this.getTabItems(); - const newTabId = generateReactKey({ prefix: "tab" }); - const newTabLabel = getNextEntityName( - "Tab ", - tabsArray.map((tab: any) => tab.label), - ); - tabs = { - ...tabs, - [newTabId]: { - id: newTabId, - index: tabsArray.length, - label: newTabLabel, - widgetId: generateReactKey(), - isVisible: true, - }, - }; - - this.updateProperty(this.props.propertyName, tabs); - }; - updateFocus = (index: number, isFocused: boolean) => { this.setState({ focusedIndex: isFocused ? index : null }); }; diff --git a/app/client/src/sagas/WidgetAdditionSagas.ts b/app/client/src/sagas/WidgetAdditionSagas.ts index 8f6d24309b..4bb8221623 100644 --- a/app/client/src/sagas/WidgetAdditionSagas.ts +++ b/app/client/src/sagas/WidgetAdditionSagas.ts @@ -33,7 +33,7 @@ import { getDataTree } from "selectors/dataTreeSelectors"; import { generateReactKey } from "utils/generators"; import { WidgetProps } from "widgets/BaseWidget"; import WidgetFactory from "utils/WidgetFactory"; -import { omit } from "lodash"; +import omit from "lodash/omit"; import produce from "immer"; import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants"; const WidgetTypes = WidgetFactory.widgetTypes; @@ -405,16 +405,15 @@ function* addNewTabChildSaga( "Tab ", tabsArray.map((tab: any) => tab.label), ); - const newTabIndex = Object.keys(tabs)?.length - 1; tabs = { ...tabs, [newTabId]: { id: newTabId, + index: tabsArray.length, label: newTabLabel, widgetId: newTabWidgetId, isVisible: true, - index: newTabIndex, }, }; const newTabProps: any = getChildTabData(tabProps, { diff --git a/app/client/src/sagas/WidgetDeletionSagas.ts b/app/client/src/sagas/WidgetDeletionSagas.ts index 458361862e..7ea1781c79 100644 --- a/app/client/src/sagas/WidgetDeletionSagas.ts +++ b/app/client/src/sagas/WidgetDeletionSagas.ts @@ -14,7 +14,7 @@ import { import { GridDefaults } from "constants/WidgetConstants"; import { ENTITY_TYPE } from "entities/AppsmithConsole"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; -import { flattenDeep, omit } from "lodash"; +import { flattenDeep, omit, orderBy } from "lodash"; import { CanvasWidgetsReduxState, FlattenedWidgetProps, @@ -54,7 +54,11 @@ function* deleteTabChildSaga( const tabWidget = allWidgets[widgetId]; if (tabWidget && tabWidget.parentId) { const tabParentWidget = allWidgets[tabWidget.parentId]; - const tabsArray: any = Object.values(tabParentWidget.tabsObj); + const tabsArray: any = orderBy( + Object.values(tabParentWidget.tabsObj), + "index", + "asc", + ); if (tabsArray && tabsArray.length === 1) return; const updatedArray = tabsArray.filter((eachItem: any, i: number) => { return i !== index;