Skip to content

Commit

Permalink
add useShouldRenderFlowEngineBackButton
Browse files Browse the repository at this point in the history
  • Loading branch information
SCjona committed Jun 19, 2024
1 parent b0fdeef commit baeca78
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/backend-components/Form/FlowEngine/FlowEngineBackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ export interface FlowEngineBackButtonProps
children?: ActionButtonProps["children"];
}

export const useShouldRenderFlowEngineBackButton = () => {
const { customProps } = useFormContextLite();
const custProps = customProps as CrudFormProps | undefined;
const isInDialog = useContext(IsInFormDialogContext);
const goBack = custProps?.goBack;
const hasCustomCloseHandler = custProps?.hasCustomSubmitHandler;
return goBack && !(isInDialog && hasCustomCloseHandler);
};

/**
* back button with same logic as DefaultFormPage back button
* @remarks Should only be rendered if useShouldRenderFlowEngineBackButton() returns true
* @param props The props
*/
const FlowEngineBackButton = (props: FlowEngineBackButtonProps) => {
const { customProps, submitting } = useFormContextLite();
const custProps = customProps as CrudFormProps | undefined;
Expand Down

0 comments on commit baeca78

Please sign in to comment.