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: make method version getting set as initial part

Brad Barbin3b92e96bcef2
diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
index 834cdc4dd8..baec56d67c 100644
--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
@@ -34,7 +34,7 @@ import {
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
-import { useEffect, useState } from "react";
+import { Fragment, useEffect, useState } from "react";
import { flushSync } from "react-dom";
import {
LuCheck,
@@ -111,8 +111,13 @@ const MakeMethodTools = ({
const [selectedVersion, setSelectedVersion] =
useState<MakeMethod>(activeMethod);
+ // Reset selectedVersion when itemId or activeMethod changes
+ useEffect(() => {
+ setSelectedVersion(activeMethod);
+ }, [itemId, activeMethod]);
+
return (
- <>
+ <Fragment key={itemId}>
<Menubar>
<HStack className="w-full justify-between">
<HStack spacing={0}>
@@ -463,7 +468,7 @@ const MakeMethodTools = ({
onCancel={activeMethodModal.onClose}
/>
)}
- </>
+ </Fragment>
);
};
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
index d9753c28e6..2ed95d0a79 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
@@ -32,7 +32,7 @@ import {
} from "@carbon/react";
import { labelSizes } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
-import { useEffect, useState } from "react";
+import { Fragment, useEffect, useState } from "react";
import {
LuChevronRight,
LuGitBranch,
@@ -254,7 +254,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
});
return (
- <>
+ <Fragment key={jobId}>
{permissions.can("update", "production") &&
(isJobMethod || isJobMakeMethod) && (
<Menubar>
@@ -618,7 +618,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
}}
/>
)}
- </>
+ </Fragment>
);
};
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
index 76eff31a06..d93cdf2e6d 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
@@ -30,7 +30,7 @@ import {
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
-import { useEffect, useState } from "react";
+import { Fragment, useEffect, useState } from "react";
import {
LuChevronRight,
LuGitBranch,
@@ -226,7 +226,7 @@ const QuoteMakeMethodTools = () => {
});
return (
- <>
+ <Fragment key={lineId}>
{line &&
permissions.can("update", "sales") &&
(isQuoteLineMethod || isQuoteMakeMethod) && (
@@ -598,7 +598,7 @@ const QuoteMakeMethodTools = () => {
}}
/>
)}
- </>
+ </Fragment>
);
};