From c08240df3f2fe0c4c5c35af471f68a2187f8e582 Mon Sep 17 00:00:00 2001 From: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:18:26 +0100 Subject: [PATCH] fix(admin-ui): Preserve decimal numbers when locale uses commas (#5641) **What** - Ensure that we format numbers with `.` as the decimal separator, even when the users locale uses `,`. This changes still allows users to use comma as the decimal separator, but the transformation we use before writing to state converts the number to use a dot instead. --- .changeset/seven-forks-knock.md | 5 +++++ .../price-list-product-prices-form.tsx | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/seven-forks-knock.md diff --git a/.changeset/seven-forks-knock.md b/.changeset/seven-forks-knock.md new file mode 100644 index 0000000000..a2fb094266 --- /dev/null +++ b/.changeset/seven-forks-knock.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +fix(admin-ui): Resolves an issue where decimal numbers would be stripped when the locale uses commas as the decimal separator diff --git a/packages/admin-ui/ui/src/domain/pricing/forms/price-list-product-prices-form/price-list-product-prices-form.tsx b/packages/admin-ui/ui/src/domain/pricing/forms/price-list-product-prices-form/price-list-product-prices-form.tsx index 845b3b2359..b9c735ee83 100644 --- a/packages/admin-ui/ui/src/domain/pricing/forms/price-list-product-prices-form/price-list-product-prices-form.tsx +++ b/packages/admin-ui/ui/src/domain/pricing/forms/price-list-product-prices-form/price-list-product-prices-form.tsx @@ -1830,6 +1830,7 @@ const Cell = React.forwardRef( ? formatValue({ value: strippedValue.replace(/,/g, "."), // If the current locale uses commas as decimal separators, then we need to replace them with dots. decimalScale: decimalScale ?? 0, + decimalSeparator: ".", disableGroupSeparators: true, }) : ""