aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/app.js b/src/app.js
index 0ff5ccb..28414d6 100644
--- a/src/app.js
+++ b/src/app.js
@@ -4721,21 +4721,26 @@ function tabsBar() {
);
}
-// On a desktop (a real pointer, a real keyboard) the amount field takes the
-// cursor the moment it appears, so a picked recipient goes straight to typing
-// the number. Once per field: it never pulls focus back after you've moved on,
-// and never off another field you're in (a zap comment) — only off nothing,
-// or off the recipient field that just resolved. Phones keep their keyboard
-// down until a tap.
-function focusSendAmount() {
+// On a desktop (a real pointer, a real keyboard) Send is ready to type into:
+// the recipient field has the cursor when the tab opens, and the amount field
+// takes it the moment it appears, so a picked recipient goes straight to
+// typing the number. Once per field per visit: it never pulls focus back after
+// you've moved on, and never off another field you're in (a zap comment) —
+// only off nothing, or (for the amount) off the recipient field that just
+// resolved. Phones keep their keyboard down until a tap.
+let sendVisit = 0, lastTabSeen = null;
+function focusSendField() {
if (matchMedia('(pointer: coarse)').matches) return;
const pane = document.querySelector('[data-send-pane]');
- const amt = pane && pane.querySelector('input[type=number]:not(:disabled)');
- if (!amt || amt._autoFocused) return;
- amt._autoFocused = true;
+ if (!pane) return;
+ const amt = pane.querySelector('input[type=number]:not(:disabled)');
+ const dest = pane.querySelector('textarea.send-dest:not(:disabled)');
+ const field = amt || dest;
+ if (!field || field._autoFocused === sendVisit) return;
+ field._autoFocused = sendVisit;
const a = document.activeElement;
- if (a && a !== document.body && !(a.classList && a.classList.contains('send-dest'))) return;
- amt.focus();
+ if (a && a !== document.body && !(amt && a.classList && a.classList.contains('send-dest'))) return;
+ field.focus();
}
function tabContent() {
@@ -4752,9 +4757,10 @@ function tabContent() {
if (detailOpen) return hist;
sendFocused = false;
const pane = ui.tab === 'receive' ? receiveTab() : sendTab();
+ if (ui.tab !== lastTabSeen) { lastTabSeen = ui.tab; if (ui.tab === 'send') sendVisit++; }
if (ui.tab === 'send' && pane && pane.setAttribute) {
pane.setAttribute('data-send-pane', '');
- requestAnimationFrame(focusSendAmount);
+ requestAnimationFrame(focusSendField);
}
// Past the recipient — an amount to enter, a payment to confirm — the
// history is one more thing on screen while you're about to send.