fix(ui): keep modal forms and actions on screen on phones

Cap modal height in dvh so it fits the visible viewport, pin trailing
action rows hand-rolled inside the body, drop nested body padding/scroll,
tighten phone padding, use 16px inputs on touch phones, and stack
form-row in narrow modals.
This commit is contained in:
Juan Denis committed 2026-11-10 02:26:33 -05:00
1 parent 6ff4ba7131
commit 998c013602
3 files changed
+82

No files matched your search

+7
View File
@@ -5,6 +5,13 @@ import { cn } from '@/lib/utils';
// (styles/components/_ui.scss → .sk-modal*). `size` picks a max-width on
// >=sm screens; mobile is always near full-width.
//
// Small screens: height is capped in dvh so the modal fits the visible
// viewport (browser bars / on-screen keyboard); on phones header/body/footer
// padding drops to 16px. A trailing .modal-actions / .modal-footer /
// .form-actions row hand-rolled inside the body (forms inside the body) sticks
// to the bottom of the scrolling body, and a nested .modal-body adds no extra
// padding or scroller. Two-column .form-row stacks in narrow modals.
//
// Form mode: pass `onSubmit` and the body AND footer
// are wrapped in one <form>. This exists because a submit button must live
// inside the form it submits — without it, every modal with a form had to
@@ -19,6 +19,7 @@
width: 100%;
max-width: 560px;
max-height: 90vh;
max-height: 90dvh;
overflow-y: auto;
@include custom-scrollbar();
}
+74
View File
@@ -343,6 +343,7 @@
width: calc(100% - #{$space-8});
max-width: 560px;
max-height: calc(100vh - #{$space-10});
max-height: calc(100dvh - #{$space-10});
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
@@ -896,6 +897,7 @@
overflow: hidden;
max-width: 32rem; // = md default
max-height: 90vh;
max-height: 90dvh;
&--sm { max-width: 24rem; }
&--md { max-width: 32rem; }
@@ -950,7 +952,44 @@
min-height: 0;
overflow-y: auto;
padding: $space-4 $space-6;
container-type: inline-size;
@include custom-scrollbar();
// Hand-rolled trailing action rows live inside the body (the form wraps
// it); pin them to the bottom of the scroll area so they stay reachable.
// Sticky offsets from the scrollport edge, so bottom: 0 is flush; the
// negative margins cancel the body padding.
.modal-actions:last-child,
.modal-footer:last-child,
.form-actions:last-child {
position: sticky;
bottom: 0;
z-index: 1;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: $space-2;
margin: $space-4 (-$space-6) (-$space-4);
padding: $space-3 $space-6;
border-top: 1px solid $border-subtle;
background: $bg-card;
}
// The outer body owns padding and scrolling.
.modal-body {
padding: 0;
max-height: none;
overflow: visible;
}
.modal-footer:not(:last-child) {
padding: $space-3 0;
}
}
// Narrow modals: stack two-column rows.
@container (max-width: 28rem) {
.sk-modal__body .form-row { grid-template-columns: 1fr; }
}
.sk-modal__footer {
@@ -963,6 +1002,41 @@
background: $bg-card;
}
@media (max-width: $breakpoint-sm) {
.ui-dialog-content { width: calc(100% - #{$space-6}); }
.sk-modal__header { padding: $space-4 $space-10 $space-4 $space-4; }
.sk-modal__body { padding: $space-4; }
.sk-modal__footer {
flex-wrap: wrap;
padding: $space-3 $space-4;
padding-bottom: calc(#{$space-3} + env(safe-area-inset-bottom, 0px));
}
.sk-modal__body {
.modal-actions:last-child,
.modal-footer:last-child,
.form-actions:last-child {
margin: $space-4 (-$space-4) (-$space-4);
padding: $space-3 $space-4;
padding-bottom: calc(#{$space-3} + env(safe-area-inset-bottom, 0px));
}
}
}
// iOS Safari zooms the page when a focused field is under 16px.
@media (max-width: $breakpoint-sm) and (pointer: coarse) {
.ui-dialog-content {
input:not([type='checkbox'], [type='radio'], [type='range'], [type='color'], [type='file']),
textarea,
select,
[role='combobox'] {
font-size: $text-md;
}
}
}
// --------------------------------------------
// CONFIRM DIALOG (components/ConfirmDialog.jsx — built on AlertDialog)
// --------------------------------------------