Skip to content

Commit

Permalink
Merge pull request #567 from enkryptcom/fix/send-input-ui-breaking-wi…
Browse files Browse the repository at this point in the history
…th-multiple-periods

fix: send input ui breaking with multiple periods
  • Loading branch information
kvhnuke authored Dec 4, 2024
2 parents 741f728 + f7ef55d commit b5b9fb0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ const isInputsValid = computed<boolean>(() => {
isSendToken.value
)
return false;
if (new BigNumber(sendAmount.value).gt(assetMaxValue.value)) return false;
const sendAmountBigNumber = new BigNumber(sendAmount.value)
if (sendAmountBigNumber.isNaN()) return false
if (sendAmountBigNumber.gt(assetMaxValue.value)) return false;
return true;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,16 @@ const amount = computed({
const onlyNumber = ($event: KeyboardEvent) => {
const keyCode = $event.keyCode ? $event.keyCode : $event.which;
if ((keyCode < 48 || keyCode > 57) && keyCode !== 46) {
$event.preventDefault();
// Numeric
if (keyCode >= /* 0 */ 48 && keyCode <= /* 9 */ 57) {
return;
}
// Only allow a single period
if (keyCode === /* '.' */ 46 && amount.value.indexOf('.') === -1) {
return;
}
// Alphabetical (/non-numeric) or mulitple periods. Don't propagate change
$event.preventDefault();
};
const changeFocus = () => {
isFocus.value = !isFocus.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ const isInputsValid = computed<boolean>(() => {
if (!isSendToken.value && !selectedNft.value.id) {
return false;
}
if (new BigNumber(sendAmount.value).gt(assetMaxValue.value)) return false;
const sendAmountBigNumber = new BigNumber(sendAmount.value)
if (sendAmountBigNumber.isNaN()) return false
if (sendAmountBigNumber.gt(assetMaxValue.value)) return false;
if (gasCostValues.value.REGULAR.nativeValue === '0') return false;
if (!isNumericPositive(sendAmount.value)) return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ const isInputsValid = computed<boolean>(() => {
if (!isSendToken.value && !selectedNft.value.id) {
return false;
}
if (new BigNumber(sendAmount.value).gt(assetMaxValue.value)) return false;
const sendAmountBigNumber = new BigNumber(sendAmount.value);
if (sendAmountBigNumber.isNaN()) return false;
if (sendAmountBigNumber.gt(assetMaxValue.value)) return false;
return true;
});
Expand Down

0 comments on commit b5b9fb0

Please sign in to comment.