From b410c512395bebcc2c38eea2b6b22a170a125de2 Mon Sep 17 00:00:00 2001 From: 8lurry Date: Wed, 1 Apr 2026 21:41:17 +0600 Subject: [PATCH] fix(InputNumber): decide prefix suffix using formatToParts --- components/lib/inputnumber/InputNumber.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index 4e9c34fcd0..423d05f6fb 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -134,7 +134,15 @@ export const InputNumber = React.memo( } else { const formatter = new Intl.NumberFormat(_locale, { style: props.mode, currency: props.currency, currencyDisplay: props.currencyDisplay }); - prefixChar.current = formatter.format(1).split('1')[0]; + // Use formatToParts instead of split('1') so that locales with + // non-ASCII numerals (e.g. Bengali ১) are handled correctly. + const parts = formatter.formatToParts(1); + const integerIndex = parts.findIndex((p) => p.type === 'integer'); + + prefixChar.current = parts + .slice(0, integerIndex) + .map((p) => p.value) + .join(''); } return new RegExp(`${escapeRegExp(prefixChar.current || '')}`, 'g'); @@ -153,7 +161,15 @@ export const InputNumber = React.memo( roundingMode: props.roundingMode }); - suffixChar.current = formatter.format(1).split('1')[1]; + // Use formatToParts instead of split('1') so that locales with + // non-ASCII numerals (e.g. Bengali ১) are handled correctly. + const parts = formatter.formatToParts(1); + const integerIndex = parts.findIndex((p) => p.type === 'integer'); + + suffixChar.current = parts + .slice(integerIndex + 1) + .map((p) => p.value) + .join(''); } return new RegExp(`${escapeRegExp(suffixChar.current || '')}`, 'g');