Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(mobile): float the phone dock over the page (#1894)

Brad Barbin923a1d14d1f9
diff --git a/apps/erp/app/components/Layout/Mobile/ChromeSlots.tsx b/apps/erp/app/components/Layout/Mobile/ChromeSlots.tsx
index 788a3ec5d4..526e7cc3b6 100644
--- a/apps/erp/app/components/Layout/Mobile/ChromeSlots.tsx
+++ b/apps/erp/app/components/Layout/Mobile/ChromeSlots.tsx
@@ -65,7 +65,11 @@ export function PhoneActionBar({
* Removed on desktop, where the stylesheet values apply unchanged.
*/
export function useCompactCssVar(
- name: "--header-height" | "--hero-height" | "--content-inset",
+ name:
+ | "--header-height"
+ | "--hero-height"
+ | "--content-inset"
+ | "--dock-height",
element: HTMLElement | null
) {
const { isPhone } = useViewport();
@@ -88,16 +92,28 @@ export function useCompactCssVar(
}
/**
- * The shell's bottom chrome: the target for <BottomBar> and the dock. Its
- * height becomes `--content-inset`, so full-height pages end above it.
+ * The shell's bottom chrome: the target for <BottomBar> and the dock. A
+ * bottom bar is in flow and its height becomes `--content-inset`, so
+ * full-height pages end above it. The dock floats over the page with nothing
+ * behind the pill; its height becomes `--dock-height`, the room a scroller
+ * leaves at its end so its last row can scroll clear of the pill.
*/
export function MobileBottomChrome({ children }: { children: ReactNode }) {
const [element, setElement] = useState<HTMLElement | null>(null);
+ const [dock, setDock] = useState<HTMLElement | null>(null);
useCompactCssVar("--content-inset", element);
+ useCompactCssVar("--dock-height", dock);
return (
- <div ref={setElement} className="md:hidden shrink-0">
- <bottomBarSlot.Target className="empty:hidden" />
- {children}
- </div>
+ <>
+ <div ref={setElement} className="md:hidden shrink-0">
+ <bottomBarSlot.Target className="empty:hidden" />
+ </div>
+ <div
+ ref={setDock}
+ className="pointer-events-none absolute inset-x-0 bottom-0 z-40 md:hidden"
+ >
+ {children}
+ </div>
+ </>
);
}
diff --git a/apps/erp/app/routes/x+/_index.tsx b/apps/erp/app/routes/x+/_index.tsx
index d7780a7f27..2bbd6517eb 100644
--- a/apps/erp/app/routes/x+/_index.tsx
+++ b/apps/erp/app/routes/x+/_index.tsx
@@ -161,7 +161,7 @@ export default function AppIndexRoute() {
return (
<div className="relative w-full h-full overflow-hidden">
<div className="relative z-10 w-full h-full overflow-y-auto">
- <div className="max-w-7xl mx-auto p-8 max-md:p-4">
+ <div className="max-w-7xl mx-auto p-8 max-md:p-4 max-md:pb-[calc(var(--dock-height,0px)+1rem)]">
<div className="mb-8">
{!CONTROLLED_ENVIRONMENT && (
<div className="max-md:hidden">
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index d01a978ef3..6f310b4b35 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -538,10 +538,10 @@ export default function AuthenticatedRoute() {
>
<PrimaryNavigation />
<div className="flex flex-1 flex-col min-w-0 overflow-hidden bg-card md:mt-2 md:mr-2 md:mb-2 md:rounded-2xl md:border md:border-border shadow-md relative z-10">
- {/* Phones: app bar on top, the dock or a page's bottom
- bar below <main>, in flow. Mounted only on phones so
- their hooks (notifications, sheets) never run on
- desktop. */}
+ {/* Phones: app bar on top; below <main>, a page's
+ bottom bar in flow or the dock floating over it.
+ Mounted only on phones so their hooks
+ (notifications, sheets) never run on desktop. */}
{isPhone && <MobileAppBar />}
<Topbar />
<main className="flex-1 overflow-y-auto scrollbar-hide relative">
@@ -551,6 +551,15 @@ export default function AuthenticatedRoute() {
values and saving wrote them to the new one. */}
<Outlet key={companyId} />
</ModuleSidebarLayout>
+ {/* Room to scroll a page's end out from under the
+ floating dock. A spacer, not padding: padding would
+ shrink h-full pages and end them above the dock. */}
+ {isPhone && (
+ <div
+ aria-hidden
+ className="h-[var(--dock-height,0px)] md:hidden"
+ />
+ )}
</main>
{isPhone && (
<MobileBottomChrome>
diff --git a/apps/erp/app/styles/tailwind.css b/apps/erp/app/styles/tailwind.css
index 741793209d..e13fac18c0 100644
--- a/apps/erp/app/styles/tailwind.css
+++ b/apps/erp/app/styles/tailwind.css
@@ -230,8 +230,8 @@ p.is-editor-empty:first-child:before {
/*
* ERP phone chrome (< 768px).
* - The app bar is 52px, so frames sized from --topbar-height still fit.
- * - Toasts sit above the bottom chrome at every phone width; Sonner's own
- * mobileOffset only applies up to 600px.
+ * - Toasts sit above the bottom chrome (bottom bar or floating dock) at
+ * every phone width; Sonner's own mobileOffset only applies up to 600px.
*/
@media (width < 48rem) {
:root {
@@ -239,6 +239,6 @@ p.is-editor-empty:first-child:before {
}
[data-sonner-toaster][data-y-position="bottom"] {
- bottom: calc(var(--content-inset, 0px) + 16px);
+ bottom: calc(var(--content-inset, 0px) + var(--dock-height, 0px) + 16px);
}
}
diff --git a/packages/react/src/Dock.tsx b/packages/react/src/Dock.tsx
index 36596927c8..3725db9e63 100644
--- a/packages/react/src/Dock.tsx
+++ b/packages/react/src/Dock.tsx
@@ -48,7 +48,7 @@ function DockBar({
return (
<nav
className={cn(
- "flex h-12 items-center gap-0.5 rounded-full border border-border bg-popover/95 p-1 shadow-lg backdrop-blur",
+ "pointer-events-auto flex h-12 items-center gap-0.5 rounded-full border border-border bg-popover/95 p-1 shadow-lg backdrop-blur",
className
)}
{...props}
@@ -59,12 +59,19 @@ function DockBar({
}
/**
- * The pill in the shell's bottom band, in flow so pages end above it.
+ * The pill in the shell's bottom band. The band is transparent and lets
+ * touches through around the pill, so the shell can float it over the page.
* `className` styles the band (e.g. `hidden`); the rest go to the pill.
*/
function Dock({ className, ...props }: HTMLAttributes<HTMLElement>) {
return (
- <div className={cn("md:hidden", dockPositionClassName, className)}>
+ <div
+ className={cn(
+ "pointer-events-none md:hidden",
+ dockPositionClassName,
+ className
+ )}
+ >
<DockBar {...props} />
</div>
);