From d7e1887221467929175e7c69b3064dc7e6c967d8 Mon Sep 17 00:00:00 2001 From: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:26:35 +0100 Subject: [PATCH] fix(admin-ui): Prevent comma decimal separator from converting inputs to NaN (#5566) **What** - Using the Price List bulk editor with a locale that uses comma as the decimal separator would convert decimal numbers to NaN. This PR fixes that by replacing commas with dots, before passing the values on to the state manager. Closes #5565 --- .changeset/breezy-suns-marry.md | 5 +++++ .../price-list-product-prices-form.tsx | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/breezy-suns-marry.md diff --git a/.changeset/breezy-suns-marry.md b/.changeset/breezy-suns-marry.md new file mode 100644 index 0000000000..6c8bac757a --- /dev/null +++ b/.changeset/breezy-suns-marry.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +fix(admin-ui): Fixes an issue where using the bulk editor with comma as the decimal separator would convert the input to NaN 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 5066e98b3e..845b3b2359 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 @@ -1511,7 +1511,7 @@ const PriceListProductPricesForm = ({ ref={tableRef} > - +
{t( @@ -1586,7 +1586,7 @@ const PriceListProductPricesForm = ({ - +
@@ -1828,7 +1828,7 @@ const Cell = React.forwardRef( */ const formattedValue = strippedValue ? formatValue({ - value: strippedValue, + value: strippedValue.replace(/,/g, "."), // If the current locale uses commas as decimal separators, then we need to replace them with dots. decimalScale: decimalScale ?? 0, disableGroupSeparators: true, }) @@ -2138,7 +2138,7 @@ const Cell = React.forwardRef( {borders.bottom && borders.right && (
)}