Override locale seperator consistently (#3253)

This commit is contained in:
Jaco Greeff 2020-07-23 11:58:07 +02:00 committed by GitHub
parent f1a38db2d4
commit ddebfec73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<meta name="theme-color" content="#000000">
<meta http-equiv="X-Frame-Options" content="deny">
<link rel="manifest" href="manifest.json">
<link rel="shortcut icon" href="favicon.ico">
<title><%= htmlWebpackPlugin.options.PAGE_TITLE %></title>

View File

@ -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',

View File

@ -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*)$'
);
}