Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/client/src/actions/widgetSelectionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export interface WidgetSelectionRequestPayload {
payload?: string[];
invokedBy?: NavigationMethod;
basePageId?: string;
parentId?: string;
}

export type WidgetSelectionRequest = (
selectionRequestType: SelectionRequestType,
payload?: string[],
invokedBy?: NavigationMethod,
basePageId?: string,
parentId?: string,
) => ReduxAction<WidgetSelectionRequestPayload>;

// Use to select a widget programmatically via platform action
Expand All @@ -23,9 +25,10 @@ export const selectWidgetInitAction: WidgetSelectionRequest = (
payload,
invokedBy?: NavigationMethod,
basePageId?: string,
parentId?: string,
) => ({
type: ReduxActionTypes.SELECT_WIDGET_INIT,
payload: { selectionRequestType, payload, basePageId, invokedBy },
payload: { selectionRequestType, payload, basePageId, invokedBy, parentId },
});

export interface SetSelectedWidgetsPayload {
Expand Down
8 changes: 7 additions & 1 deletion app/client/src/sagas/WidgetDeletionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,13 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
// close property pane after delete
yield put(closePropertyPane());
yield put(
selectWidgetInitAction(SelectionRequestType.Unselect, [widgetId]),
selectWidgetInitAction(
SelectionRequestType.Unselect,
[widgetId],
undefined,
undefined,
parentId,
),
);
yield call(postDelete, widgetId, widgetName, otherWidgetsToDelete);
}
Expand Down
27 changes: 19 additions & 8 deletions app/client/src/sagas/WidgetSelectionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function* selectWidgetSaga(action: ReduxAction<WidgetSelectionRequestPayload>) {
const {
basePageId,
invokedBy,
parentId,
payload = [],
selectionRequestType,
} = action.payload;
Expand Down Expand Up @@ -93,8 +94,9 @@ function* selectWidgetSaga(action: ReduxAction<WidgetSelectionRequestPayload>) {
// It is possible that the payload is empty.
// These properties can be used for a finding sibling widgets for certain types of selections
const widgetId = payload[0];
const parentId: string | undefined =
widgetId in allWidgets ? allWidgets[widgetId].parentId : undefined;
const finalParentId: string | undefined =
parentId ||
(widgetId in allWidgets ? allWidgets[widgetId].parentId : undefined);

if (
widgetId &&
Expand All @@ -115,7 +117,7 @@ function* selectWidgetSaga(action: ReduxAction<WidgetSelectionRequestPayload>) {
}
case SelectionRequestType.One:
case SelectionRequestType.Create: {
assertParentId(parentId);
assertParentId(finalParentId);
newSelection = selectOneWidget(payload);
break;
}
Expand All @@ -124,10 +126,10 @@ function* selectWidgetSaga(action: ReduxAction<WidgetSelectionRequestPayload>) {
break;
}
case SelectionRequestType.ShiftSelect: {
assertParentId(parentId);
assertParentId(finalParentId);
const siblingWidgets: string[] = yield select(
getWidgetImmediateChildren,
parentId,
finalParentId,
);
newSelection = shiftSelectWidgets(
payload,
Expand All @@ -138,10 +140,10 @@ function* selectWidgetSaga(action: ReduxAction<WidgetSelectionRequestPayload>) {
break;
}
case SelectionRequestType.PushPop: {
assertParentId(parentId);
assertParentId(finalParentId);
const siblingWidgets: string[] = yield select(
getWidgetImmediateChildren,
parentId,
finalParentId,
);
newSelection = pushPopWidgetSelection(
payload,
Expand All @@ -151,7 +153,16 @@ function* selectWidgetSaga(action: ReduxAction<WidgetSelectionRequestPayload>) {
break;
}
case SelectionRequestType.Unselect: {
newSelection = unselectWidget(payload, selectedWidgets);
const isParentExists = finalParentId
? finalParentId in allWidgets
: false;

if (isParentExists) {
assertParentId(finalParentId);
newSelection = [finalParentId];
} else {
newSelection = unselectWidget(payload, selectedWidgets);
}
break;
}
case SelectionRequestType.All: {
Expand Down