From f21ebec84d3207ed7eab7d712315adc8ab706708 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 7 Oct 2026 13:39:15 -0700 Subject: Desktop: Send opens with the cursor in the recipient field (once per visit, never off another field, never on phones); the amount field still takes it once a recipient resolves Co-Authored-By: Claude Opus 5.5 --- src/app.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/app.js') 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. -- cgit v1.2.3