I have a Saga which listens to the FormEngineEvent “VALUE_CHANGE” for my Datepicker, which works fine.
However if this Saga dispatches an action to create a ModalNotification Activity weird things start to happen:
The original FormEngineEvent “VALUE_CHANGE” is dispatched once again but with the old values (the old stored values and not the changes like in the first “value changed” action).
Does adding a ModalNotification trigger any redispatches or block anything to explain this behaviour?
See the code below:
import { Action } from "typescript-fsa";
import { Activity, ActivityActions } from "@com.mgmtp.a12.client/client-core/lib/core/activity";
import { ApplicationSaga } from "@com.mgmtp.a12.client/client-core/lib/core/application";
import { put, take } from "redux-saga/effects";
import { SagaIterator } from "redux-saga";
import {
ModalNotification, ModalNotificationProps
} from "@com.mgmtp.a12.widgets/widgets-core/lib/modal-notification";
export const setZuarbeitDateRangesSaga = (): ApplicationSaga.Descriptor[] => {
return [
{
canHandle: (ad: Activity.Descriptor, action: Action<{}>) => {
return (
action.type == "Activity/FORM-ENGINE-EVENT" &&
(action.payload as any).engineEvent?.type == "form-engine/event/VALUE_CHANGE" &&
("officialDateRange" == (action.payload as any).engineEvent?.payload?.path[2]?.elementName)
);
},
handle: (action: Action<any>) => {
return setZuarbeitDateRanges(action);
}
}
];
};
function* setZuarbeitDateRanges(action: any): SagaIterator {
yield take(ActivityActions.setData)
yield take(ActivityActions.setDirty)
yield put(ActivityActions.create({
activityId: "MODAL_CONFIRMATION",
loadingState: "without",
activityDescriptor: { view: "ModalNotificationView" },
data: {
title: "",
message: "",
buttons: [],
variant: "warning",
}
}));
}
export function ModalNotificationView2(
props: ModalNotificationProps
): JSX.Element | null {
const { children, ...modalProps } = props;
return (
<ModalNotification {...modalProps} padding={18}>
{children}
</ModalNotification>
);
}
A Screenshot how it looks like in the store. As I said, the second FormEngineEvent after the ModalNotification-Push shouldn´t be there and only appears if the ModalNotifcation is created.
