diff --git a/app/client/src/sagas/WidgetOperationSagas.tsx b/app/client/src/sagas/WidgetOperationSagas.tsx index 4a4b8b48ca..59de3ac0c3 100644 --- a/app/client/src/sagas/WidgetOperationSagas.tsx +++ b/app/client/src/sagas/WidgetOperationSagas.tsx @@ -40,6 +40,7 @@ import { SetWidgetDynamicPropertyPayload, updateWidgetProperty, UpdateWidgetPropertyPayload, + updateWidgetPropertyRequest, UpdateWidgetPropertyRequestPayload, } from "actions/controlActions"; import { @@ -433,6 +434,23 @@ export function* deleteSaga(deleteAction: ReduxAction) { // SPECIAL HANDLING FOR TABS IN A TABS WIDGET if (parent.type === WidgetTypes.TABS_WIDGET && widget.tabName) { widgetName = widget.tabName; + // Deleting a tab from the explorer doesn't remove the same + // from the "tabs" property of the widget. + // So updating the widget property here when the children length doesn't match + // `tabs` length + if (parent.children?.length !== parent.tabs.length) { + const filteredTabs = parent.tabs.filter( + (tab: any) => tab.widgetId !== widgetId, + ); + yield put( + updateWidgetPropertyRequest( + parentId, + "tabs", + filteredTabs, + RenderModes.CANVAS, + ), + ); + } } if (saveStatus && !disallowUndo) { Toaster.show({