From 39e4990a7f37f67f2729858b3a67524119dcd475 Mon Sep 17 00:00:00 2001 From: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Date: Thu, 4 Mar 2021 15:24:01 +0530 Subject: [PATCH] Fix: Deleting a tab from a tab widget from the explorer would not reflect in the canvas(#3218) --- app/client/src/sagas/WidgetOperationSagas.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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({