Migrate DeleteServerModal to tailwind components

This commit is contained in:
Alejandro Celaya
2025-04-05 07:16:24 +02:00
parent fd40e2b7bc
commit 7879476739
5 changed files with 39 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
import type { FC, ReactElement } from 'react';
import { useCallback, useState } from 'react';
import { useCallback, useEffect , useState } from 'react';
export type RenderModalArgs = {
open: boolean;
@@ -12,5 +12,13 @@ export const TestModalWrapper: FC<{ renderModal: (args: RenderModalArgs) => Reac
const [open, setOpen] = useState(true);
const onClose = useCallback(() => setOpen(false), []);
// Workaround to ensure CardModals from shlink-frontend-shared can be closed, as they depend on CSS transitions
// Since JSDOM does not support them, this dispatches the event right after the listener has been set-up
useEffect(() => {
if (!open) {
document.querySelector('[data-testid="transition-container"]')?.dispatchEvent(new Event('transitionend'));
}
}, [open]);
return renderModal({ open, onClose });
};