fix: keep mobile portal menu reachable
This commit is contained in:
1 parent
0085c721af
commit
60d5a95651
3 files changed
+40
-5
No files matched your search
@@ -195,6 +195,28 @@ a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mobile-portal-menu-panel {
|
||||||
|
animation: mobile-portal-menu-enter 150ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes mobile-portal-menu-enter {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-0.5rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.mobile-portal-menu-panel {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.public-account-page {
|
.public-account-page {
|
||||||
display: grid;
|
display: grid;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
|||||||
@@ -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");
|
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", () => {
|
test("closes after navigation, Escape and an outside pointer interaction", () => {
|
||||||
render(
|
render(
|
||||||
<div>
|
<div>
|
||||||
@@ -62,7 +73,9 @@ test("closes after navigation, Escape and an outside pointer interaction", () =>
|
|||||||
|
|
||||||
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
|
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
|
||||||
fireEvent.click(trigger);
|
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");
|
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
||||||
|
|
||||||
fireEvent.click(trigger);
|
fireEvent.click(trigger);
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMen
|
|||||||
{open ? (
|
{open ? (
|
||||||
<div
|
<div
|
||||||
id={menuId}
|
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}
|
{sectionLabel}
|
||||||
</p>
|
</p>
|
||||||
<nav aria-label="Mobile Navigation" className="grid gap-1">
|
<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}
|
aria-current={active ? "page" : undefined}
|
||||||
className={active
|
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 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)}
|
onClick={() => setOpen(false)}
|
||||||
>
|
>
|
||||||
{item.label}
|
{item.label}
|
||||||
@@ -91,7 +91,7 @@ export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMen
|
|||||||
})}
|
})}
|
||||||
</nav>
|
</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">
|
<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 />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 border-t border-border px-3 pt-2 [&>button]:min-h-11">
|
<div className="mt-2 border-t border-border px-3 pt-2 [&>button]:min-h-11">
|
||||||
|
|||||||
Reference in new issue
Block a user