fix: keep mobile portal menu reachable

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 17:35:26 +02:00
1 parent 0085c721af
commit 60d5a95651
3 files changed
+40 -5

No files matched your search

@@ -52,6 +52,17 @@ test("keeps nested theme and logout buttons at least 44px tall", () => {
expect(logoutButton.parentElement?.getAttribute("class")).toContain("[&>button]:min-h-11");
});
test("caps the open panel to the dynamic viewport and keeps every action scrollable", () => {
render(<MobilePortalMenu nav={nav} sectionLabel="Administration" />);
fireEvent.click(screen.getByRole("button", { name: /menü öffnen/i }));
const panel = screen.getByRole("navigation", { name: /mobile navigation/i }).parentElement;
expect(panel?.getAttribute("class")).toContain("max-h-[calc(100dvh-5.5rem)]");
expect(panel?.getAttribute("class")).toContain("overflow-y-auto");
expect(panel?.getAttribute("class")).toContain("overscroll-contain");
});
test("closes after navigation, Escape and an outside pointer interaction", () => {
render(
<div>
@@ -62,7 +73,9 @@ test("closes after navigation, Escape and an outside pointer interaction", () =>
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
fireEvent.click(trigger);
fireEvent.click(screen.getByRole("link", { name: "Audit" }));
const auditLink = screen.getByRole("link", { name: "Audit" });
auditLink.addEventListener("click", (event) => event.preventDefault(), { once: true });
fireEvent.click(auditLink);
expect(trigger.getAttribute("aria-expanded")).toBe("false");
fireEvent.click(trigger);
+4 -4
View File
@@ -67,9 +67,9 @@ export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMen
{open ? (
<div
id={menuId}
className="absolute right-0 top-[calc(100%+0.75rem)] z-50 w-[min(22rem,calc(100vw-2rem))] animate-in fade-in slide-in-from-top-2 rounded-xl border border-border bg-background p-2 shadow-xl duration-150 motion-reduce:animate-none"
className="mobile-portal-menu-panel absolute right-0 top-[calc(100%+0.75rem)] z-50 max-h-[calc(100dvh-5.5rem)] w-[min(22rem,calc(100vw-2rem))] overflow-y-auto overscroll-contain rounded-xl border border-border bg-background p-2 shadow-xl"
>
<p className="px-3 py-2 text-xs font-bold uppercase tracking-widest text-muted-foreground">
<p className="px-3 py-2 text-xs font-bold uppercase tracking-widest text-[var(--muted)]">
{sectionLabel}
</p>
<nav aria-label="Mobile Navigation" className="grid gap-1">
@@ -82,7 +82,7 @@ export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMen
aria-current={active ? "page" : undefined}
className={active
? "flex min-h-11 items-center rounded-lg bg-foreground px-3 font-semibold text-background"
: "flex min-h-11 items-center rounded-lg px-3 font-medium hover:bg-muted"}
: "flex min-h-11 items-center rounded-lg px-3 font-medium hover:bg-[var(--soft)]"}
onClick={() => setOpen(false)}
>
{item.label}
@@ -91,7 +91,7 @@ export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMen
})}
</nav>
<div className="mt-2 flex min-h-11 items-center justify-between border-t border-border px-3 pt-2 [&>button]:min-h-11 [&>button]:min-w-11">
<span className="text-sm text-muted-foreground">Darstellung</span>
<span className="text-sm text-[var(--muted)]">Darstellung</span>
<ThemeToggle />
</div>
<div className="mt-2 border-t border-border px-3 pt-2 [&>button]:min-h-11">