Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with SupportForm not being submittable #10619

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/replay-next/components/errors/ModalFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function ModalFrame({
}: {
children: ReactNode;
dataTestId?: string;
onDismiss: () => void;
onDismiss?: () => void;
showCloseButton?: boolean;
title: ReactNode;
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function UnexpectedErrorFormSuspends({ details, replayClient, title, unexpectedE
return (
<ModalFrame
dataTestId="UnexpectedErrorDetails"
onDismiss={noop}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was acting as the "outer one" as per the comment I added:

// 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

showCloseButton={!!supportFormState}
title={<span data-test-name="ErrorTitle">{title}</span>}
>
Expand Down Expand Up @@ -109,5 +108,3 @@ function UnexpectedErrorFormSuspends({ details, replayClient, title, unexpectedE
</ModalFrame>
);
}

function noop() {}
8 changes: 6 additions & 2 deletions packages/replay-next/src/hooks/useModalDismissSignal.ts
Original file line number Diff line number Diff line change
@@ -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<HTMLDivElement> | RefObject<HTMLDivElement>,
dismissCallback: () => void,
dismissCallback: (() => void) | undefined,
dismissOnClickOutside: boolean = true
) {
useEffect(() => {
const element = modalRef.current;
if (element === null) {
if (element === null || !dismissCallback) {
return;
}

Expand Down
8 changes: 6 additions & 2 deletions src/ui/hooks/useModalDismissSignal.ts
Original file line number Diff line number Diff line change
@@ -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<HTMLDivElement> | RefObject<HTMLDivElement>,
dismissCallback: () => void,
dismissCallback: (() => void) | undefined,
dismissOnClickOutside: boolean = true
) {
useEffect(() => {
const element = modalRef.current;
if (element === null) {
if (element === null || !dismissCallback) {
return;
}

Expand Down
Loading