Skip to content

Commit

Permalink
fix: input field issues
Browse files Browse the repository at this point in the history
  • Loading branch information
martines3000 committed Oct 8, 2024
1 parent 070de40 commit 569fb4b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions apps/frontend/src/components/InputDialog/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,13 @@ export const InputField = ({ error }: { error: boolean }) => {
`${tokenAmount.toString()}.` !== inputValue
) {
const tokenAmountStr = tokenAmount.toString();
const [inputIntegerPart, inputDecimalPart = ''] = inputValue.split('.');
const [tokenIntegerPart, tokenDecimalPart = ''] =
tokenAmountStr.split('.');
const [_, inputDecimalPart = ''] = inputValue.split('.');
const [__, tokenDecimalPart = ''] = tokenAmountStr.split('.');

const hasTrailingZeros =
inputDecimalPart.length > tokenDecimalPart.length &&
inputDecimalPart.endsWith('0');
if (
(!hasTrailingZeros &&
tokenIntegerPart === inputIntegerPart &&
tokenDecimalPart !== inputDecimalPart) ||
inputValue === ''
) {
if (!hasTrailingZeros || inputValue === '') {
BigNumber.config({ EXPONENTIAL_AT: 20 });
setInputValue(tokenAmountStr);
}
Expand Down

0 comments on commit 569fb4b

Please sign in to comment.