From 1172f4853cc390fa2ca576661568b7d164191e55 Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Tue, 1 Dec 2026 09:32:34 +1100 Subject: [PATCH] fix(app): open the discard confirm above the edit alert modal The confirm dialog and the edit alert modal both used Mantine's default modal z-index, so the confirm opened behind the editor and the modal could not be closed. Give the confirm a z-index above every app modal. Fixes HDX-6235 --- .changeset/confirm-above-modals.md | 5 +++ .../app/src/__tests__/useConfirm.test.tsx | 34 +++++++++++++++++++ packages/app/src/useConfirm.tsx | 3 ++ 3 files changed, 42 insertions(+) create mode 100644 .changeset/confirm-above-modals.md create mode 100644 packages/app/src/__tests__/useConfirm.test.tsx diff --git a/.changeset/confirm-above-modals.md b/.changeset/confirm-above-modals.md new file mode 100644 index 0000000000..0bbf540ec1 --- /dev/null +++ b/.changeset/confirm-above-modals.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/app': patch +--- + +fix: the "discard unsaved changes" confirm no longer opens behind the edit alert modal, which left the modal impossible to close diff --git a/packages/app/src/__tests__/useConfirm.test.tsx b/packages/app/src/__tests__/useConfirm.test.tsx new file mode 100644 index 0000000000..2528708404 --- /dev/null +++ b/packages/app/src/__tests__/useConfirm.test.tsx @@ -0,0 +1,34 @@ +import { getDefaultZIndex, Modal } from '@mantine/core'; +import { screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; + +import { ConfirmProvider, useConfirm } from '@/useConfirm'; + +jest.mock('next/router', () => ({ + useRouter: () => ({ events: { on: jest.fn(), off: jest.fn() } }), +})); + +function ModalThatConfirms() { + const confirm = useConfirm(); + return ( + {}} title="Editor"> + + + ); +} + +describe('ConfirmProvider', () => { + it('stacks the confirm above a modal at the default z-index', async () => { + renderWithMantine( + + + , + ); + + await userEvent.click(screen.getByRole('button', { name: 'Close' })); + + const confirmModal = await screen.findByTestId('confirm-modal'); + const zIndex = Number(confirmModal.style.getPropertyValue('--mb-z-index')); + expect(zIndex).toBeGreaterThan(getDefaultZIndex('modal')); + }); +}); diff --git a/packages/app/src/useConfirm.tsx b/packages/app/src/useConfirm.tsx index f84374c0f7..b652d64d0f 100644 --- a/packages/app/src/useConfirm.tsx +++ b/packages/app/src/useConfirm.tsx @@ -71,6 +71,9 @@ export function ConfirmProvider({ children }: { children: React.ReactNode }) { onClose={state?.onClose ?? (() => {})} centered withCloseButton={false} + // Above every app modal (some go to 9999) so it never opens behind + // the one that asked; below notifications and spotlight. + zIndex={100_000} > {state?.message}