diff options
| author | Adam Soltys <[email protected]> | 2026-10-07 13:39:15 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-07 13:39:15 -0700 |
| commit | f21ebec84d3207ed7eab7d712315adc8ab706708 (patch) | |
| tree | 5ba5b1caf8af10cefa33d09816c73241e72661bd /src | |
| parent | 9277ed5f287711b28ea5ca7ab86dfd659721a329 (diff) | |
| download | coinosv3-f21ebec84d3207ed7eab7d712315adc8ab706708.tar.gz coinosv3-f21ebec84d3207ed7eab7d712315adc8ab706708.zip | |
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 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.js | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -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. |
