From 5d4e6e21957436f9bdb0dd3f3f2c0294cbd2743a Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:08:34 -0400 Subject: [PATCH] HPCC-32409 ECL Watch v9 add onDismiss property to MessageBox allows the calling component to specify any additional tasks to be done other than simply hiding the MessageBox on cancel Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- esp/src/src-react/layouts/MessageBox.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/esp/src/src-react/layouts/MessageBox.tsx b/esp/src/src-react/layouts/MessageBox.tsx index a7286cc7c3b..caa17875078 100644 --- a/esp/src/src-react/layouts/MessageBox.tsx +++ b/esp/src/src-react/layouts/MessageBox.tsx @@ -48,6 +48,7 @@ interface MessageBoxProps { show: boolean; modeless?: boolean; blocking?: boolean; + onDismiss?: () => void; setShow: (_: boolean) => void; footer?: React.ReactNode; children?: React.ReactNode; @@ -59,6 +60,7 @@ export const MessageBox: React.FunctionComponent = ({ show, modeless = true, blocking = true, + onDismiss, setShow, footer, children @@ -71,7 +73,12 @@ export const MessageBox: React.FunctionComponent = ({ body: { padding: "12px 24px 12px 24px", overflowY: "hidden" }, }), [theme.palette.themePrimary, minWidth]); - const close = React.useCallback(() => setShow(false), [setShow]); + const close = React.useCallback(() => { + if (onDismiss) { + onDismiss(); + } + setShow(false); + }, [onDismiss, setShow]); return