forge
Explore
Log in

Don't you dare go Hollow

📱 keep modal surfaces out from under the system bars

Browse files at this commit

a6408c3f840031b794525bef3a525ad5fe8daab5Burak BoduroğluParent: 4448c06
  • fix
    • 📱 keep modal surfaces out from under the system bars
Show full message
fix: 📱 keep modal surfaces out from under the system bars
- side panels, dialogs and alert dialogs are positioned against the raw
  viewport, so on a phone their header — title and close button — sat under
  the status bar and their footer behind the gesture bar; a form that opens
  with no visible way to close it reads as the app having frozen
- all three now inset themselves by the safe area, and dialogs cap their
  height at the inset box instead of 90vh so a tall one is never clipped
- the gesture-bar height is read from the shell's HezarfenShell bridge in
  the boot script rather than waiting to be pushed in: a value pushed into
  a document dies with that document, so a reload lost the inset and the
  tab bar dropped back under the gesture pill
- the nav sheet is only role=dialog while it is open — mounted permanently,
  it was answering every [role=dialog] query and sitting in the
  accessibility tree beside whatever modal was really open
index.htmlmodified+8 -0
@@ -22,6 +22,14 @@
2222 if (dark) document.documentElement.classList.add("dark");
2323 const locale = localStorage.getItem("hezarfen.locale");
2424 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+ }
2533 } catch {}
2634 })();
2735 </script>
src/components/layout/mobile-nav-sheet.tsxmodified+5 -2
@@ -82,8 +82,11 @@ export function MobileNavSheet(props: {
8282 />
8383
8484 <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}
8790 aria-label={t("nav.menu")}
8891 class={cn(
8992 "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">(
1717 return (
1818 <AlertDialogPrimitive.Portal>
1919 <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))]">
2122 <AlertDialogPrimitive.Content
2223 class={cn(
2324 "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">(
2020 <DialogPrimitive.Portal>
2121 <DialogPrimitive.Overlay class="fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-opacity duration-200" />
2222 {/* 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">
2426 <DialogPrimitive.Content
2527 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",
2729 local.class,
2830 )}
2931 // 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(
4545 <DialogPrimitive.Content
4646 class={cn(
4747 "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))]",
4852 "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",
4953 width(),
5054 props.class,