From ddebfec73ecf492bd3e4a491b17737356b9a95fa Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 23 Jul 2020 11:58:07 +0200 Subject: [PATCH] Override locale seperator consistently (#3253) --- packages/apps/public/index.html | 1 - packages/react-components/src/Input.tsx | 10 +++++----- packages/react-components/src/InputNumber.tsx | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/apps/public/index.html b/packages/apps/public/index.html index 108471d3aa..c9efd8fa30 100644 --- a/packages/apps/public/index.html +++ b/packages/apps/public/index.html @@ -3,7 +3,6 @@ - <%= htmlWebpackPlugin.options.PAGE_TITLE %> diff --git a/packages/react-components/src/Input.tsx b/packages/react-components/src/Input.tsx index b412d79c87..f4e28347e2 100644 --- a/packages/react-components/src/Input.tsx +++ b/packages/react-components/src/Input.tsx @@ -52,10 +52,10 @@ interface Props { withEllipsis?: boolean; } -// Find decimal separator used in current locale -const getDecimalSeparator = (): string => 1.1 - .toLocaleString() - .replace(/\d/g, ''); +// // Find decimal separator used in current locale +// const getDecimalSeparator = (): string => 1.1 +// .toLocaleString() +// .replace(/\d/g, ''); // note: KeyboardEvent.keyCode and KeyboardEvent.which are deprecated const KEYS = { @@ -67,7 +67,7 @@ const KEYS = { C: 'c', CMD: 'Meta', CTRL: 'Control', - DECIMAL: getDecimalSeparator(), + // DECIMAL: getDecimalSeparator(), ENTER: 'Enter', ESCAPE: 'Escape', TAB: 'Tab', diff --git a/packages/react-components/src/InputNumber.tsx b/packages/react-components/src/InputNumber.tsx index 2e1f771e3d..bb3e14c7f8 100644 --- a/packages/react-components/src/InputNumber.tsx +++ b/packages/react-components/src/InputNumber.tsx @@ -13,7 +13,7 @@ import { BN_ZERO, BN_TEN, formatBalance, isBn } from '@polkadot/util'; import { classes } from './util'; import { BitLengthOption } from './constants'; import Dropdown from './Dropdown'; -import Input, { KEYS, KEYS_PRE } from './Input'; +import Input, { KEYS_PRE } from './Input'; import { useTranslation } from './translate'; interface Props { @@ -59,9 +59,11 @@ function getGlobalMaxValue (bitLength?: number): BN { } function getRegex (isDecimal: boolean): RegExp { + const decimal = '.'; + return new RegExp( isDecimal - ? `^(0|[1-9]\\d*)(\\${KEYS.DECIMAL}\\d*)?$` + ? `^(0|[1-9]\\d*)(\\${decimal}\\d*)?$` : '^(0|[1-9]\\d*)$' ); }