diff --git a/src/components/sidebar/sidebar.component.tsx b/src/components/sidebar/sidebar.component.tsx index 43452e8e..8fd6a1d7 100644 --- a/src/components/sidebar/sidebar.component.tsx +++ b/src/components/sidebar/sidebar.component.tsx @@ -16,6 +16,7 @@ interface SidebarProps { onCancel: () => void; handleClose: () => void; hideFormCollapseToggle: () => void; + hideControls?: boolean; } const Sidebar: React.FC = ({ @@ -25,6 +26,7 @@ const Sidebar: React.FC = ({ onCancel, handleClose, hideFormCollapseToggle, + hideControls, }) => { const { t } = useTranslation(); const { pages, pagesWithErrors, activePages, evaluatedPagesVisibility } = usePageObserver(); @@ -53,32 +55,34 @@ const Sidebar: React.FC = ({ requestPage={requestPage} /> ))} - {sessionMode !== 'view' &&
} + {sessionMode !== 'view' && !hideControls &&
} -
- {sessionMode !== 'view' && ( - + )} + - )} - -
+ + )} ); }; diff --git a/src/form-engine.component.tsx b/src/form-engine.component.tsx index 3fbf0a1c..cc9bc72c 100644 --- a/src/form-engine.component.tsx +++ b/src/form-engine.component.tsx @@ -19,6 +19,7 @@ import MarkdownWrapper from './components/inputs/markdown/markdown-wrapper.compo import PatientBanner from './components/patient-banner/patient-banner.component'; import Sidebar from './components/sidebar/sidebar.component'; import styles from './form-engine.scss'; +import { useExternalSubmitListener } from './hooks/useExternalSubmitListener'; interface FormEngineProps { patientUUID: string; @@ -33,6 +34,7 @@ interface FormEngineProps { handleClose?: () => void; handleConfirmQuestionDeletion?: (question: Readonly) => Promise; markFormAsDirty?: (isDirty: boolean) => void; + hideControls?: boolean; } const FormEngine = ({ @@ -48,6 +50,7 @@ const FormEngine = ({ handleClose, handleConfirmQuestionDeletion, markFormAsDirty, + hideControls = false, }: FormEngineProps) => { const { t } = useTranslation(); const session = useSession(); @@ -107,11 +110,13 @@ const FormEngine = ({ markFormAsDirty?.(isFormDirty); }, [isFormDirty]); - const handleSubmit = useCallback((e: React.FormEvent) => { - e.preventDefault(); + const handleSubmit = useCallback((e?: React.FormEvent) => { + e?.preventDefault(); setIsSubmitting(true); }, []); + useExternalSubmitListener(handleSubmit); + return (
{isLoadingPatient || isLoadingFormJson ? ( @@ -152,6 +157,7 @@ const FormEngine = ({ onCancel={onCancel} handleClose={handleClose} hideFormCollapseToggle={hideFormCollapseToggle} + hideControls={hideControls} /> )}
@@ -167,7 +173,7 @@ const FormEngine = ({ setIsLoadingFormDependencies={setIsLoadingDependencies} />
- {showBottomButtonSet && ( + {showBottomButtonSet && !hideControls && (