diff --git a/packages/core/src/utils/currency.ts b/packages/core/src/utils/currency.ts index 37e64c71..4e9c658b 100644 --- a/packages/core/src/utils/currency.ts +++ b/packages/core/src/utils/currency.ts @@ -577,6 +577,9 @@ const defaultOptions = { export type AppendUnitsOptions = { plural?: boolean | undefined; lowercase?: boolean | undefined; + /* Default behavior for built in toLocaleString is to not show the unit when it's + the default unit in the locale (when using default currencyDisplay). We'll do the same. */ + showForCurrentLocaleUnit?: boolean | undefined; }; type FormatCurrencyStrOptions = { @@ -675,6 +678,14 @@ export function formatCurrencyStr( } if (options?.appendUnits) { + const localeCurrencyCode = localeToCurrencyCode(currentLocale); + if ( + unit === localeCurrencyCode && + !options.appendUnits.showForCurrentLocaleUnit + ) { + return formattedStr; + } + const unitStr = abbrCurrencyUnit(unit); const unitSuffix = options.appendUnits.plural && num > 1 ? "s" : ""; const unitStrWithSuffix = `${unitStr}${unitSuffix}`; diff --git a/packages/ui/src/components/CurrencyAmount.tsx b/packages/ui/src/components/CurrencyAmount.tsx index efad9500..9914ff09 100644 --- a/packages/ui/src/components/CurrencyAmount.tsx +++ b/packages/ui/src/components/CurrencyAmount.tsx @@ -65,8 +65,9 @@ export function CurrencyAmount({ ? undefined : showUnits === true ? ({ - plural: true, - lowercase: true, + plural: false, + lowercase: false, + showForCurrentLocaleUnit: false, } as const) : showUnits;