mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
fix(ui): keep date/time pickers inside their dialog
The add and edit surfaces could be scrolled sideways and the time picker sat past the right edge: measurements, mood, the medication intake editor and the cycle log sheet all showed it, so the cause is in what they share. Two mechanisms, both in shared primitives. DateField and TimeField wrap a text input. A flex item's min-width:auto resolves to a content-based minimum, and for a text input that is its intrinsic size attribute — 20 characters, about 180px. Neither field could render below ~230px whatever width the parent offered, so the date + time row demanded ~470px inside a 400px dialog body and pushed the clock button 58px past the edge. min-w-0 on the field box and on the overlay input releases that floor; the row now fits at every width from 360px up. The scrolling body only declares overflow-y. CSS promotes the other axis from visible to auto, so every deliberate outward bleed in the tree turned the form into a pannable surface — SheetSection's trigger row was 8px wider than its own container for no benefit (a focus ring already draws outside the box), and Switch's hit-target pseudo reaches 13px past the track. The bodies and the dialog surface now state overflow-x explicitly, the section trigger no longer bleeds, and the dialog's grid column is pinned so an over-wide child cannot drag the surface out with it. Measured before and after on the four reported surfaces at 360 / 390 / 430 / 768 / 1280 / 1440: the date/time row spilled 83px on every width from 640px up and none of it remains. An e2e spec asserts the two harms directly — the surface is not a horizontal scroll container, and no focusable control lies outside its visible box — with a canary that proves the reachability check can fail.
This commit is contained in:
1 parent
d5f176ac4d
commit
eb5c8a91fb
7 files changed
+333
-15
No files matched your search
@@ -69,7 +69,24 @@ function DialogContent({
|
||||
// viewport on short / soft-keyboard-collapsed mobile screens.
|
||||
// Consumers that need a different ceiling can override via
|
||||
// `className`.
|
||||
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
|
||||
//
|
||||
// `grid-cols-[minmax(0,1fr)]` pins the implicit column. A bare
|
||||
// `grid` gives its single column an `auto` track, which sizes to the
|
||||
// widest child's max-content and grows the box past the dialog's own
|
||||
// `max-w-*` — and because `overflow-y:auto` makes `overflow-x`
|
||||
// compute to `auto`, that surplus becomes a horizontal scrollbar
|
||||
// rather than a visible spill. `minmax(0,1fr)` caps the track at the
|
||||
// dialog width so an over-wide child is contained instead of
|
||||
// dragging the surface out with it.
|
||||
//
|
||||
// `overflow-x-clip` pairs with it: `overflow-y-auto` alone promotes
|
||||
// the other axis from `visible` to `auto`, so a single over-wide
|
||||
// child made the whole dialog pannable sideways. A dialog scrolls
|
||||
// vertically; anything that genuinely needs sideways scroll brings
|
||||
// its own `overflow-x-auto` wrapper. Consumers that set `overflow-*`
|
||||
// themselves still win — `<ResponsiveSheet>` passes
|
||||
// `overflow-hidden` and scrolls its body instead.
|
||||
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] grid-cols-[minmax(0,1fr)] gap-4 overflow-x-clip overflow-y-auto rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
Reference in new issue
Block a user