mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-18 23:04:25 +01:00
fix amountbox bug
This commit is contained in:
committed by
Tony Giorgio
parent
f5e12d1b7c
commit
e1c2a386ff
@@ -161,7 +161,6 @@ export const AmountEditable: ParentComponent<{
|
|||||||
const isFiatMode = mode() === "fiat";
|
const isFiatMode = mode() === "fiat";
|
||||||
const inputSanitizer = isFiatMode ? fiatInputSanitizer : satsInputSanitizer;
|
const inputSanitizer = isFiatMode ? fiatInputSanitizer : satsInputSanitizer;
|
||||||
const localValue = isFiatMode ? localFiat : localSats;
|
const localValue = isFiatMode ? localFiat : localSats;
|
||||||
const inputRef = isFiatMode ? fiatInputRef : satsInputRef;
|
|
||||||
|
|
||||||
let sane;
|
let sane;
|
||||||
|
|
||||||
@@ -184,7 +183,7 @@ export const AmountEditable: ParentComponent<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// After a button press make sure we re-focus the input
|
// After a button press make sure we re-focus the input
|
||||||
inputRef.focus();
|
focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFixedAmount(amount: string) {
|
function setFixedAmount(amount: string) {
|
||||||
@@ -220,17 +219,24 @@ export const AmountEditable: ParentComponent<{
|
|||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
setMode((m) => (m === "sats" ? "fiat" : "sats"));
|
setMode((m) => (m === "sats" ? "fiat" : "sats"));
|
||||||
if (mode() === "sats") {
|
focus();
|
||||||
satsInputRef.focus();
|
|
||||||
} else {
|
|
||||||
fiatInputRef.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
satsInputRef.focus();
|
focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function focus() {
|
||||||
|
// Make sure we actually have the inputs mounted before we try to focus them
|
||||||
|
if (isOpen() && satsInputRef && fiatInputRef) {
|
||||||
|
if (mode() === "sats") {
|
||||||
|
satsInputRef.focus();
|
||||||
|
} else {
|
||||||
|
fiatInputRef.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Root open={isOpen()}>
|
<Dialog.Root open={isOpen()}>
|
||||||
<button
|
<button
|
||||||
@@ -297,12 +303,9 @@ export const AmountEditable: ParentComponent<{
|
|||||||
<For each={mode() === "fiat" ? FIXED_AMOUNTS_USD : FIXED_AMOUNTS_SATS}>
|
<For each={mode() === "fiat" ? FIXED_AMOUNTS_USD : FIXED_AMOUNTS_SATS}>
|
||||||
{(amount) => (
|
{(amount) => (
|
||||||
<button
|
<button
|
||||||
onClick={() => { setFixedAmount(amount.amount)
|
onClick={() => {
|
||||||
if (mode() === "fiat") {
|
setFixedAmount(amount.amount);
|
||||||
fiatInputRef.focus();
|
focus();
|
||||||
} else {
|
|
||||||
satsInputRef.focus();
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
class="py-2 px-4 rounded-lg bg-white/10"
|
class="py-2 px-4 rounded-lg bg-white/10"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user