Skip to content

Commit

Permalink
Update ConditionBuilderContent.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
amal-k-joy authored Dec 9, 2024
1 parent 92793e2 commit cc76db4
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ const ConditionBuilderContent = ({
}, [actionState]);
useEffect(() => {
if (initialState?.enabledDefault) {
setRootState?.(initialState.state);
setRootState?.(initialConditionState.current as ConditionBuilderState);
initialConditionState.current = null;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialState]);
Expand All @@ -119,17 +120,12 @@ const ConditionBuilderContent = ({

const onRemove = useCallback(
(groupId) => {
const groups = rootState?.groups?.filter(
(group) => groupId !== group?.id
);
setRootState?.({
...rootState,
groups: rootState ? groups : [],
groups: rootState
? rootState?.groups?.filter((group) => groupId !== group?.id)
: [],
});
//set the initial state to empty.
if (groups?.length === 0) {
initialConditionState.current = null;
}
},
[setRootState, rootState]
);
Expand Down

0 comments on commit cc76db4

Please sign in to comment.