diff --git a/packages/replay-next/components/errors/ModalFrame.tsx b/packages/replay-next/components/errors/ModalFrame.tsx
index 24ff38de6e9..d32923391d4 100644
--- a/packages/replay-next/components/errors/ModalFrame.tsx
+++ b/packages/replay-next/components/errors/ModalFrame.tsx
@@ -15,7 +15,7 @@ export function ModalFrame({
}: {
children: ReactNode;
dataTestId?: string;
- onDismiss: () => void;
+ onDismiss?: () => void;
showCloseButton?: boolean;
title: ReactNode;
}) {
diff --git a/packages/replay-next/components/errors/UnexpectedErrorForm.tsx b/packages/replay-next/components/errors/UnexpectedErrorForm.tsx
index 87e33635ff9..2165875b9b1 100644
--- a/packages/replay-next/components/errors/UnexpectedErrorForm.tsx
+++ b/packages/replay-next/components/errors/UnexpectedErrorForm.tsx
@@ -61,7 +61,6 @@ function UnexpectedErrorFormSuspends({ details, replayClient, title, unexpectedE
return (
{title}}
>
@@ -109,5 +108,3 @@ function UnexpectedErrorFormSuspends({ details, replayClient, title, unexpectedE
);
}
-
-function noop() {}
diff --git a/packages/replay-next/src/hooks/useModalDismissSignal.ts b/packages/replay-next/src/hooks/useModalDismissSignal.ts
index eb623639b89..b2b11629094 100644
--- a/packages/replay-next/src/hooks/useModalDismissSignal.ts
+++ b/packages/replay-next/src/hooks/useModalDismissSignal.ts
@@ -1,14 +1,18 @@
import { MutableRefObject, RefObject, useEffect } from "react";
+// TODO: this doesn't work correctly when multiple stacked modals are open
+// they are unaware of each other and the global listeners added by them compete between each other
+// in a way that the "outer" can perform its action and call `.preventDefault` - preventing the "inner" one from closing
+
// Closes a modal dialog if the user clicks outside of it or types "Escape"
export default function useModalDismissSignal(
modalRef: MutableRefObject | RefObject,
- dismissCallback: () => void,
+ dismissCallback: (() => void) | undefined,
dismissOnClickOutside: boolean = true
) {
useEffect(() => {
const element = modalRef.current;
- if (element === null) {
+ if (element === null || !dismissCallback) {
return;
}
diff --git a/src/ui/hooks/useModalDismissSignal.ts b/src/ui/hooks/useModalDismissSignal.ts
index e8cb668392a..5ea85b1db25 100644
--- a/src/ui/hooks/useModalDismissSignal.ts
+++ b/src/ui/hooks/useModalDismissSignal.ts
@@ -1,14 +1,18 @@
import { MutableRefObject, RefObject, useEffect } from "react";
+// TODO: this doesn't work correctly when multiple stacked modals are open
+// they are unaware of each other and the global listeners added by them compete between each other
+// in a way that the "outer" can perform its action and call `.preventDefault` - preventing the "inner" one from closing
+
// Closes a modal dialog if the user clicks outside of it or types "Escape"
export default function useModalDismissSignal(
modalRef: MutableRefObject | RefObject,
- dismissCallback: () => void,
+ dismissCallback: (() => void) | undefined,
dismissOnClickOutside: boolean = true
) {
useEffect(() => {
const element = modalRef.current;
- if (element === null) {
+ if (element === null || !dismissCallback) {
return;
}