Skip to content

Commit

Permalink
Fix: Prevent conflict with suffix separator
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnson committed Dec 6, 2024
1 parent 73f413b commit 096c0b6
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CustomAmountProps = {
onValueChange?: (value: string, name?: string, values?: CurrencyInputOnChangeValues) => void;
};

const formatter = new Intl.NumberFormat();
const formatter = new Intl.NumberFormat(navigator.language);
const groupSeparator = formatter.format(1000).replace(/[0-9]/g, '');
const decimalSeparator = formatter.format(1.1).replace(/[0-9]/g, '');

Expand All @@ -35,7 +35,13 @@ const CustomAmount = (
}}
disableAbbreviations
decimalSeparator={decimalSeparator}
groupSeparator={groupSeparator}
groupSeparator={
/**
* Replace non-breaking space to avoid conflict with the suffix separator.
* @link https://github.com/cchanxzy/react-currency-input-field/issues/266
*/
groupSeparator.replace(/\u00A0/g, ' ')
}
className="givewp-fields-amount__input givewp-fields-amount__input-custom"
aria-invalid={fieldError ? 'true' : 'false'}
id="amount-custom"
Expand Down

0 comments on commit 096c0b6

Please sign in to comment.