Fix: Deleting a tab from a tab widget from the explorer would not reflect in the canvas(#3218)

This commit is contained in:
akash-codemonk 2021-03-04 15:24:01 +05:30 committed by GitHub
parent 1e4878f983
commit 39e4990a7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,7 @@ import {
SetWidgetDynamicPropertyPayload,
updateWidgetProperty,
UpdateWidgetPropertyPayload,
updateWidgetPropertyRequest,
UpdateWidgetPropertyRequestPayload,
} from "actions/controlActions";
import {
@ -433,6 +434,23 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
// 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({