Skip to content

Commit 75ca0c4

Browse files
shivamG640lordrip
authored andcommitted
Fix: Deleting the empty container node with placeholder node asks for confirmation
1 parent bb5865e commit 75ca0c4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/ui/src/components/Visualization/Custom/hooks/delete-step.hook.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useDeleteStep = (vizNode: IVisualizationNode) => {
1414
const deleteModalContext = useContext(ActionConfirmationModalContext);
1515
const childrenNodes = vizNode.getChildren();
1616
const hasChildren = childrenNodes !== undefined && childrenNodes.length > 0;
17+
const isPlaceholderNode = hasChildren && childrenNodes.length === 1 && childrenNodes[0].data.isPlaceholder;
1718
const { getRegisteredInteractionAddons } = useContext(NodeInteractionAddonContext);
1819

1920
const onDeleteStep = useCallback(async () => {
@@ -22,7 +23,7 @@ export const useDeleteStep = (vizNode: IVisualizationNode) => {
2223
);
2324

2425
let modalAnswer: string | undefined = ACTION_ID_CONFIRM;
25-
if (hasChildren || modalCustoms.length > 0) {
26+
if ((hasChildren && !isPlaceholderNode) || modalCustoms.length > 0) {
2627
const additionalModalText = modalCustoms.length > 0 ? modalCustoms[0].additionalText : undefined;
2728
const buttonOptions = modalCustoms.length > 0 ? modalCustoms[0].buttonOptions : undefined;
2829
/** Open delete confirm modal, get the confirmation */

packages/ui/src/components/Visualization/Custom/hooks/replace-step.hook.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const useReplaceStep = (vizNode: IVisualizationNode) => {
2020
const replaceModalContext = useContext(ActionConfirmationModalContext);
2121
const childrenNodes = vizNode.getChildren();
2222
const hasChildren = childrenNodes !== undefined && childrenNodes.length > 0;
23+
const isPlaceholderNode = hasChildren && childrenNodes.length === 1 && childrenNodes[0].data.isPlaceholder;
2324
const { getRegisteredInteractionAddons } = useContext(NodeInteractionAddonContext);
2425

2526
const onReplaceNode = useCallback(async () => {
@@ -29,7 +30,7 @@ export const useReplaceStep = (vizNode: IVisualizationNode) => {
2930
getRegisteredInteractionAddons(IInteractionAddonType.ON_DELETE, vn),
3031
);
3132
let modalAnswer: string | undefined = ACTION_ID_CONFIRM;
32-
if (hasChildren) {
33+
if (hasChildren && !isPlaceholderNode) {
3334
const additionalModalText = modalCustoms.length > 0 ? modalCustoms[0].additionalText : undefined;
3435
const buttonOptions = modalCustoms.length > 0 ? modalCustoms[0].buttonOptions : undefined;
3536
/** Open delete confirm modal, get the confirmation */

0 commit comments

Comments
 (0)