aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.js')
-rw-r--r--src/app.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/app.js b/src/app.js
index 4f42529..0138de2 100644
--- a/src/app.js
+++ b/src/app.js
@@ -4674,6 +4674,23 @@ 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() {
+ 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;
+ const a = document.activeElement;
+ if (a && a !== document.body && !(a.classList && a.classList.contains('send-dest'))) return;
+ amt.focus();
+}
+
function tabContent() {
if (ui.tab === 'settings') return settingsTab();
if (ui.tab === 'history') return historyTab();
@@ -4688,7 +4705,10 @@ function tabContent() {
if (detailOpen) return hist;
sendFocused = false;
const pane = ui.tab === 'receive' ? receiveTab() : sendTab();
- if (ui.tab === 'send' && pane && pane.setAttribute) pane.setAttribute('data-send-pane', '');
+ if (ui.tab === 'send' && pane && pane.setAttribute) {
+ pane.setAttribute('data-send-pane', '');
+ requestAnimationFrame(focusSendAmount);
+ }
// 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.
if (ui.tab === 'send' && sendFocused) return pane;