Skip to content

Commit

Permalink
Merge pull request #28567 from ishpaul777/fix/not-able-delete-digit-b…
Browse files Browse the repository at this point in the history
…efore-decimal

fix: update add leading zero to delete digit before decimal
  • Loading branch information
MonilBhavsar authored Oct 6, 2023
2 parents f7ac376 + c506fbe commit e448a7e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libs/MoneyRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function stripDecimalsFromAmount(amount: string): string {
* @param amount - Changed amount from user input
*/
function addLeadingZero(amount: string): string {
return amount === '.' ? '0.' : amount;
return amount.startsWith('.') ? `0${amount}` : amount;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/steps/MoneyRequestAmountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function MoneyRequestAmountForm({amount, currency, isEditing, forwardedRef, onCu
if (currentAmount.length > 0) {
const selectionStart = selection.start === selection.end ? selection.start - 1 : selection.start;
const newAmount = `${currentAmount.substring(0, selectionStart)}${currentAmount.substring(selection.end)}`;
setNewAmount(newAmount);
setNewAmount(MoneyRequestUtils.addLeadingZero(newAmount));
}
return;
}
Expand Down

0 comments on commit e448a7e

Please sign in to comment.