Skip to content

Commit cb56025

Browse files
committed
fix(modals): fix animation of the modals + remove comments
1 parent 7b0990d commit cb56025

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

src/features/common/components/dialog.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,27 @@ const DialogContent = React.forwardRef<React.ElementRef<typeof DialogPrimitive.C
4343

4444
return (
4545
<DialogPortal>
46-
<DialogOverlay className={cn(mounted.current && 'data-[state=open]:animate-in data-[state=open]:fade-in-0')} />
46+
<DialogOverlay
47+
className={cn(
48+
'fixed inset-0 z-50 bg-black/80',
49+
mounted.current &&
50+
'data-[state=open]:animate-in data-[state=open]:fade-in data-[state=closed]:animate-out data-[state=closed]:fade-out'
51+
)}
52+
/>
4753
<DialogPrimitive.Content
4854
ref={ref}
4955
className={cn(
50-
'fixed top-0 w-full h-full md:w-auto md:h-auto md:left-[50%] md:top-[50%] z-50 grid md:translate-x-[-50%] md:translate-y-[-50%] gap-3 border bg-background shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] md:rounded-lg pt-4 [&:has(h2)]:pt-2.5',
56+
'fixed top-0 left-0 w-full h-full md:w-auto md:h-auto md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2 z-50 grid gap-3 border bg-background shadow-lg duration-200 md:rounded-lg pt-4 [&:has(h2)]:pt-2.5',
5157
mounted.current &&
52-
'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
58+
'data-[state=open]:animate-in data-[state=open]:fade-in data-[state=closed]:animate-out data-[state=closed]:fade-out',
5359
className
5460
)}
5561
{...props}
5662
tabIndex={undefined}
5763
>
5864
{children}
5965
{!hideClose && (
60-
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
66+
<DialogPrimitive.Close className="absolute top-4 right-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-hidden">
6167
<Cross2Icon className="size-4" />
6268
<span className="sr-only">Close</span>
6369
</DialogPrimitive.Close>

src/features/layout/constants/menu-items.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// src/features/layout/config/menu-items.ts
2-
31
import { Telescope, FlaskConical, Coins } from 'lucide-react'
42
import SvgWizard from '@/features/common/components/icons/wizard'
53
import { Urls } from '@/routes/urls'
64

7-
// ✅ Use an array of objects so it can be iterated
85
export const menuItems = [
96
{
107
urlTemplate: Urls.Network.Explore,

src/features/network/components/network-configs-table.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,24 @@ export function NetworkConfigsTable() {
4848
</Button>
4949
</div>
5050
<DataTable ariaLabel={networkConfigsTableLabel} columns={tableColumns} data={data} dataContext="networkConfig" />
51-
<Dialog open={createNetworkConfigDialogOpen} onOpenChange={setCreateNetworkConfigDialogOpen} modal={true}>
52-
{createNetworkConfigDialogOpen && (
53-
<DialogContent className="bg-card" aria-label={createNetworkConfigDialogLabel}>
54-
<Description hidden={true}>Create a network</Description>
55-
<DialogHeader className="flex-row items-center space-y-0">
56-
<DialogTitle asChild>
57-
<h2>{createNetworkConfigDialogLabel}</h2>
58-
</DialogTitle>
59-
</DialogHeader>
60-
<MediumSizeDialogBody>
61-
<CreateNetworkConfigForm onSuccess={() => setCreateNetworkConfigDialogOpen(false)} />
62-
</MediumSizeDialogBody>
63-
</DialogContent>
64-
)}
51+
<Dialog open={createNetworkConfigDialogOpen} onOpenChange={setCreateNetworkConfigDialogOpen} modal>
52+
<DialogContent
53+
className="bg-card"
54+
onOpenAutoFocus={(e) => e.preventDefault()} // same as the first modal
55+
aria-label={createNetworkConfigDialogLabel}
56+
>
57+
<Description hidden>Create a network</Description>
58+
59+
<DialogHeader className="flex-row items-center space-y-0">
60+
<DialogTitle asChild>
61+
<h2>{createNetworkConfigDialogLabel}</h2>
62+
</DialogTitle>
63+
</DialogHeader>
64+
65+
<MediumSizeDialogBody>
66+
<CreateNetworkConfigForm onSuccess={() => setCreateNetworkConfigDialogOpen(false)} />
67+
</MediumSizeDialogBody>
68+
</DialogContent>
6569
</Dialog>
6670
</div>
6771
)

0 commit comments

Comments
 (0)