Skip to content

Commit

Permalink
fix: dialog content screen overflow (#109)
Browse files Browse the repository at this point in the history
If the screen gets small enough for the dialog content to overflow it,
the content is not scrollable and the user has no chance to see all of
it. This can easily happen on mobile with keyboard open.

The solution I chose is to limit the height to viewport height and
let the browser handle the overflow by showing a scrollbar.
  • Loading branch information
daelmaak authored Aug 5, 2024
1 parent a1dddfb commit 946eed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/old-cameras-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"solidui-cli": patch
---

It makes dialog content vertically scrollable should it overflow the vertical space given by the viewport.
2 changes: 1 addition & 1 deletion apps/docs/src/registry/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const DialogContent = <T extends ValidComponent = "div">(
<DialogOverlay />
<DialogPrimitive.Content
class={cn(
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg duration-200 data-[expanded]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[expanded]:fade-in-0 data-[closed]:zoom-out-95 data-[expanded]:zoom-in-95 data-[closed]:slide-out-to-left-1/2 data-[closed]:slide-out-to-top-[48%] data-[expanded]:slide-in-from-left-1/2 data-[expanded]:slide-in-from-top-[48%] sm:rounded-lg",
"fixed left-1/2 top-1/2 z-50 grid max-h-screen w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto border bg-background p-6 shadow-lg duration-200 data-[expanded]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[expanded]:fade-in-0 data-[closed]:zoom-out-95 data-[expanded]:zoom-in-95 data-[closed]:slide-out-to-left-1/2 data-[closed]:slide-out-to-top-[48%] data-[expanded]:slide-in-from-left-1/2 data-[expanded]:slide-in-from-top-[48%] sm:rounded-lg",
props.class
)}
{...rest}
Expand Down

0 comments on commit 946eed2

Please sign in to comment.