Skip to content

Commit f5c2251

Browse files
fix(pos-app): replace Intl.NumberFormat.formatToParts with format to support Hermes (#410)
* fix(pos-app): replace Intl.NumberFormat.formatToParts with format to support Hermes formatToParts is not available in Hermes, causing crashes when pressing number buttons in the amount input. Replace with a simpler approach using format() which extracts the group separator by stripping all digits. Fixes crash on Android/iOS when entering amount. * fix(pos-app): bump versionCode and fix misleading comment Increment Android versionCode to 20 and update comment in getGroupSeparator to accurately describe the digit-stripping approach. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8f62970 commit f5c2251

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

dapps/pos-app/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"android.permission.BLUETOOTH_ADVERTISE",
4242
"android.permission.USB_PERMISSION"
4343
],
44-
"versionCode": 19
44+
"versionCode": 20
4545
},
4646
"web": {
4747
"output": "static",

dapps/pos-app/components/big-amount-input/utils/formatAmount.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ export function parseRawValue(rawValue: string): number {
3232
}
3333

3434
function getGroupSeparator(locale: SupportedLocale): string {
35-
const parts = new Intl.NumberFormat(locale).formatToParts(10000);
36-
return parts.find((p) => p.type === "group")?.value ?? ",";
35+
// Avoid formatToParts — not supported in Hermes
36+
const formatted = new Intl.NumberFormat(locale).format(10000);
37+
// Strip all digits — what remains is the group separator (e.g. "," or ".")
38+
const sep = formatted.replace(/\d/g, "");
39+
return sep.charAt(0) || ",";
3740
}
3841

3942
function addThousandsSeparators(integerStr: string, separator: string): string {

0 commit comments

Comments
 (0)