📱 keep modal surfaces out from under the system bars
Browse files at this commita6408c3f840031b794525bef3a525ad5fe8daab5Parent: 4448c06- fix
- 📱 keep modal surfaces out from under the system bars
5 changed files +23 -5
- index.html +8 -0
- src/components/layout/mobile-nav-sheet.tsx +5 -2
- src/components/ui/alert-dialog.tsx +2 -1
- src/components/ui/dialog.tsx +4 -2
- src/components/ui/side-panel.tsx +4 -0
index.htmlmodified+8 -0
| @@ -22,6 +22,14 @@ | ||
| 22 | 22 | if (dark) document.documentElement.classList.add("dark"); |
| 23 | 23 | const locale = localStorage.getItem("hezarfen.locale"); |
| 24 | 24 | if (locale === "en" || locale === "tr") document.documentElement.lang = locale; |
| 25 | + // Android reports only the display cutout through CSS env(), so the | |
| 26 | + // gesture bar is invisible to the page. The Tauri shell exposes its | |
| 27 | + // height here; read before first paint so nothing renders under it. | |
| 28 | + // Absent in a browser, where env(safe-area-inset-bottom) is enough. | |
| 29 | + const shell = window.HezarfenShell; | |
| 30 | + if (shell && typeof shell.bottomInsetPx === "function") { | |
| 31 | + document.documentElement.style.setProperty("--android-nav-inset", shell.bottomInsetPx() + "px"); | |
| 32 | + } | |
| 25 | 33 | } catch {} |
| 26 | 34 | })(); |
| 27 | 35 | </script> |
src/components/layout/mobile-nav-sheet.tsxmodified+5 -2
| @@ -82,8 +82,11 @@ export function MobileNavSheet(props: { | ||
| 82 | 82 | /> |
| 83 | 83 | |
| 84 | 84 | <div |
| 85 | - role="dialog" | |
| 86 | - aria-modal="true" | |
| 85 | + // Only a dialog while it is actually up: left on permanently, this | |
| 86 | + // off-screen panel would answer every [role=dialog] query and sit in | |
| 87 | + // the accessibility tree next to whatever modal is really open. | |
| 88 | + role={props.open ? "dialog" : undefined} | |
| 89 | + aria-modal={props.open ? "true" : undefined} | |
| 87 | 90 | aria-label={t("nav.menu")} |
| 88 | 91 | class={cn( |
| 89 | 92 | "absolute inset-x-0 bottom-0 flex max-h-[75vh] flex-col rounded-t-3xl border-t border-border bg-background", |
src/components/ui/alert-dialog.tsxmodified+2 -1
| @@ -17,7 +17,8 @@ export function AlertDialogContent<T extends ValidComponent = "div">( | ||
| 17 | 17 | return ( |
| 18 | 18 | <AlertDialogPrimitive.Portal> |
| 19 | 19 | <AlertDialogPrimitive.Overlay class="fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-opacity" /> |
| 20 | - <div class="fixed inset-0 z-50 flex items-center justify-center p-4"> | |
| 20 | + {/* Inset by the system bars — see dialog.tsx. */} | |
| 21 | + <div class="fixed inset-0 z-50 flex items-center justify-center p-4 pb-[calc(1rem+max(env(safe-area-inset-bottom),var(--android-nav-inset,0px)))] pt-[calc(1rem+env(safe-area-inset-top))]"> | |
| 21 | 22 | <AlertDialogPrimitive.Content |
| 22 | 23 | class={cn( |
| 23 | 24 | "w-full max-w-md overflow-hidden border border-border/80 bg-background text-foreground shadow-2xl shadow-black/20 outline-hidden animate-fade-up sm:rounded-lg", |
src/components/ui/dialog.tsxmodified+4 -2
| @@ -20,10 +20,12 @@ export function DialogContent<T extends ValidComponent = "div">( | ||
| 20 | 20 | <DialogPrimitive.Portal> |
| 21 | 21 | <DialogPrimitive.Overlay class="fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-opacity duration-200" /> |
| 22 | 22 | {/* flex center — animate-fade-up must not own transform positioning */} |
| 23 | - <div class="pointer-events-none fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4"> | |
| 23 | + {/* The centring box is inset by the system bars, so a tall dialog is | |
| 24 | + never clipped by the status bar or the gesture bar. */} | |
| 25 | + <div class="pointer-events-none fixed inset-0 z-50 flex items-center justify-center p-3 pb-[calc(0.75rem+max(env(safe-area-inset-bottom),var(--android-nav-inset,0px)))] pt-[calc(0.75rem+env(safe-area-inset-top))] sm:p-4"> | |
| 24 | 26 | <DialogPrimitive.Content |
| 25 | 27 | class={cn( |
| 26 | - "pointer-events-auto relative flex max-h-[min(90vh,48rem)] w-full max-w-lg flex-col overflow-hidden border border-border/80 bg-background text-foreground shadow-2xl shadow-black/20 outline-hidden animate-fade-up sm:rounded-lg", | |
| 28 | + "pointer-events-auto relative flex max-h-[min(100%,48rem)] w-full max-w-lg flex-col overflow-hidden border border-border/80 bg-background text-foreground shadow-2xl shadow-black/20 outline-hidden animate-fade-up sm:rounded-lg", | |
| 27 | 29 | local.class, |
| 28 | 30 | )} |
| 29 | 31 | // Standard dialogs dismiss outside/ESC; pass false only when losing |
src/components/ui/side-panel.tsxmodified+4 -0
| @@ -45,6 +45,10 @@ export function SidePanel( | ||
| 45 | 45 | <DialogPrimitive.Content |
| 46 | 46 | class={cn( |
| 47 | 47 | "fixed inset-y-0 right-0 z-50 flex h-full w-full flex-col border-l border-border bg-background text-foreground shadow-2xl shadow-black/20 outline-hidden", |
| 48 | + // The panel spans the whole display, so it has to keep its own | |
| 49 | + // header out from under the status bar and its footer off the | |
| 50 | + // gesture bar. Both insets are 0 in a desktop browser. | |
| 51 | + "pt-[env(safe-area-inset-top)] pb-[max(env(safe-area-inset-bottom),var(--android-nav-inset,0px))]", | |
| 48 | 52 | "transition-[transform,opacity] duration-200 ease-out data-closed:translate-x-full data-closed:opacity-0 data-expanded:translate-x-0 data-expanded:opacity-100", |
| 49 | 53 | width(), |
| 50 | 54 | props.class, |