PayFlow: hacky focus management for modal

This commit is contained in:
Anton Kovalenko 2021-07-18 00:31:56 +03:00
parent 3f5163fa55
commit ceea807b81
3 changed files with 9 additions and 3 deletions

View File

@ -215,4 +215,4 @@
</SiteCard>
</SiteDeck>
<PayFlow bind:lnurl={getInvoiceFor}/>
<PayFlow bind:lnurl={getInvoiceFor} hasAmount={amounts[payway.id]}/>

View File

@ -16,6 +16,7 @@
let input;
export let value = null;
export let isComplete = false;
export let focusOnMount = false;
let maskRef, imask, unmask, attrs;
@ -55,6 +56,8 @@
onMount(() => {
maskRef = IMask(input, imask);
if (focusOnMount)
input.focus();
setValue(value);
});

View File

@ -10,6 +10,7 @@
import Tipped from './Tipped.svelte';
export let lnurl = undefined;
export let hasAmount;
let isOpen;
let res1;
let res2;
@ -87,7 +88,9 @@
</script>
<Modal {isOpen} toggle={dismiss} on:open={()=>cancelButton.focus()} size='lg'>
<Modal {isOpen} toggle={dismiss}
on:open="{()=>{if (hasAmount) cancelButton.focus()}}"
size='lg'>
<ModalHeader>BOLT11 invoice: {stage}</ModalHeader>
<ModalBody>
{#if confirmAmount}
@ -97,7 +100,7 @@
<div class="input-group">
{#key minSendSat}
<InputMask bind:value={amount}
autofocus
focusOnMount={true}
unmask
imask={{
mask: Number, scale:0,