Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
makafsal committed Dec 11, 2024
2 parents ddb1121 + ea0989a commit 0aa4d5c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ const ConditionBuilderContent = ({
}, [actionState]);
useEffect(() => {
if (initialState?.enabledDefault) {
setRootState?.(initialConditionState.current as ConditionBuilderState);
initialConditionState.current = null;
setRootState?.(initialState.state);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialState]);
Expand All @@ -120,12 +119,17 @@ const ConditionBuilderContent = ({

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

0 comments on commit 0aa4d5c

Please sign in to comment.