diff --git a/src/Create.tsx b/src/Create.tsx index 1960db41d..7d0fdae8f 100644 --- a/src/Create.tsx +++ b/src/Create.tsx @@ -60,11 +60,13 @@ import { enableWebln } from "./utils/webln"; const Create = () => { let receiveAmountRef: HTMLInputElement, sendAmountRef: HTMLInputElement; - // if btc and amount > 100, switch to sat + // if btc and amount > 99, switch to sat // user failed to notice the non satoshi denomination const changeDenomination = (amount: number) => { if (denomination() === denominations.btc && amount > 99) { setDenomination(denominations.sat); + } else if (denomination() === denominations.sat && amount < 1) { + setDenomination(denominations.btc); } }; @@ -109,6 +111,9 @@ const Create = () => { const validateInput = (evt: KeyboardEvent) => { const input = evt.currentTarget as HTMLInputElement; const keycode = evt.key; + if (denomination() == "sat" && keycode === ".") { + setDenomination(denominations.btc); + } const hasDot = input.value.includes("."); const regex = denomination() == "sat" || hasDot ? /[0-9]/ : /[0-9]|\./; if (!regex.test(keycode)) { @@ -120,6 +125,7 @@ const Create = () => { const validatePaste = (evt: ClipboardEvent) => { const clipboardData = evt.clipboardData || globalThis.clipboardData; const pastedData = clipboardData.getData("Text").trim(); + changeDenomination(Number(pastedData)); if (!getValidationRegex().test(pastedData)) { evt.stopPropagation(); evt.preventDefault();