diff options
| author | Adam Soltys <[email protected]> | 2026-10-07 11:48:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-07 11:48:58 -0700 |
| commit | 5b6cdd95a3769ba897ae845590c7cbff0096e532 (patch) | |
| tree | 4228eb95fb0b809aee3c12d749c939fb28190b36 /src | |
| parent | 3227fa8ca1ef57fff3e2242dc84899482ea9b260 (diff) | |
| download | coinosv3-5b6cdd95a3769ba897ae845590c7cbff0096e532.tar.gz coinosv3-5b6cdd95a3769ba897ae845590c7cbff0096e532.zip | |
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 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.js | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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; |
