Skip to content

Commit ac3a5b2

Browse files
author
Brian Casel
committed
fixed tall modals
1 parent 03cd235 commit ac3a5b2

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

app/frontend/components/design-system/sections/elements/ModalSection.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export function ModalSection() {
4545
<>
4646
Built on Radix Dialog. Three sizes (<code>sm</code>,{" "}
4747
<code>md</code>, <code>lg</code>). Always uses an overlay and a
48-
close button. Focus is trapped while open.
48+
close button. Focus is trapped while open. If content is taller
49+
than the viewport, the modal caps its height and scrolls
50+
vertically so the top and bottom stay reachable.
4951
</>
5052
}
5153
whenToUse={
@@ -99,6 +101,35 @@ export function ModalSection() {
99101
</DialogFooter>
100102
</DialogContent>
101103
</Dialog>
104+
105+
<Dialog>
106+
<DialogTrigger asChild>
107+
<Button variant="secondary">Open tall</Button>
108+
</DialogTrigger>
109+
<DialogContent>
110+
<DialogHeader>
111+
<DialogTitle>Terms of service</DialogTitle>
112+
<DialogDescription>
113+
When a modal is taller than the viewport, it scrolls
114+
vertically — try resizing the window shorter.
115+
</DialogDescription>
116+
</DialogHeader>
117+
<div className="space-y-3">
118+
{Array.from({ length: 12 }).map((_, i) => (
119+
<p key={i}>
120+
Section {i + 1}. Lorem ipsum dolor sit amet, consectetur
121+
adipiscing elit. Sed do eiusmod tempor incididunt ut
122+
labore et dolore magna aliqua. Ut enim ad minim veniam,
123+
quis nostrud exercitation ullamco laboris.
124+
</p>
125+
))}
126+
</div>
127+
<DialogFooter>
128+
<Button variant="ghost">Decline</Button>
129+
<Button>Accept</Button>
130+
</DialogFooter>
131+
</DialogContent>
132+
</Dialog>
102133
</div>
103134
}
104135
code={code}
@@ -108,6 +139,7 @@ export function ModalSection() {
108139
<li>Always include <code>&lt;DialogTitle&gt;</code> — required for screen readers.</li>
109140
<li>Use <code>&lt;DialogDescription&gt;</code> for the supporting copy line.</li>
110141
<li>Buttons live inside <code>&lt;DialogFooter&gt;</code>; right-aligned on desktop, stacked on mobile.</li>
142+
<li>Content taller than the viewport scrolls vertically inside the modal automatically.</li>
111143
</ul>
112144
}
113145
/>

app/frontend/styles/design-system.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@
223223
@apply fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2;
224224
@apply rounded-lg border border-hairline bg-page p-6 shadow-lg;
225225
@apply max-w-lg;
226+
/* Cap height to the viewport (1rem clearance top + bottom) and scroll
227+
within, so content taller than the screen stays fully reachable. */
228+
@apply max-h-[calc(100dvh-2rem)] overflow-y-auto;
226229
}
227230
.modal-small { @apply max-w-md; }
228231
.modal-large { @apply max-w-2xl; }

0 commit comments

Comments
 (0)