From 5b6cdd95a3769ba897ae845590c7cbff0096e532 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 7 Oct 2026 11:48:58 -0700 Subject: Desktop: the Send amount field takes the cursor as soon as it appears (once; never off another field, never on phones) Co-Authored-By: Claude Opus 5.5 --- src/app.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/app.js') 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; -- cgit v1.2.3