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(erp,mes): switching company remounts the page

Sidwebworks688d5d92d928
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index 7ac0208d8a..ef1f9f7f16 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -522,7 +522,10 @@ export default function AuthenticatedRoute() {
<Topbar />
<main className="flex-1 overflow-y-auto scrollbar-hide relative">
<ModuleSidebarLayout>
- <Outlet />
+ {/* A company switch stays on the same page. Without the key the page
+ keeps its state, so a form still held the previous company's
+ values and saving wrote them to the new one. */}
+ <Outlet key={companyId} />
</ModuleSidebarLayout>
</main>
</div>
diff --git a/apps/mes/app/routes/x+/_layout.tsx b/apps/mes/app/routes/x+/_layout.tsx
index 86c3d6fef0..4fbcec91d7 100644
--- a/apps/mes/app/routes/x+/_layout.tsx
+++ b/apps/mes/app/routes/x+/_layout.tsx
@@ -523,7 +523,10 @@ export default function AuthenticatedRoute() {
timeCardEnabled={timeCardEnabled}
/>
<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">
- <Outlet />
+ {/* A company switch stays on the same page. Without the key the page
+ keeps its state, so a form still held the previous company's
+ values and saving wrote them to the new one. */}
+ <Outlet key={companyId} />
</div>
<ShortcutHelp />
{timeCardEnabled && (