diff options
| author | Adam Soltys <[email protected]> | 2026-10-07 13:47:09 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-07 13:47:09 -0700 |
| commit | 3ffe565b3d50539470a05b1f7a65f5fed419daf5 (patch) | |
| tree | ed1af8a501c8db6a01af2bff0f2fc4dad7b9bf39 /src | |
| parent | 20c9a87850f034071990067ed0dc042503e6deaf (diff) | |
| download | coinosv3-3ffe565b3d50539470a05b1f7a65f5fed419daf5.tar.gz coinosv3-3ffe565b3d50539470a05b1f7a65f5fed419daf5.zip | |
Desktop Send focus: a mouse click leaves the Send button focused, and that blocked the recipient field — only a field you're typing in is protected now (test opens Send with a real click)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.js | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -4725,11 +4725,12 @@ function tabsBar() { // 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; +// 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 (for the amount) off the recipient field that just resolved. +// Leaving Send takes its fields off the page, so coming back builds new ones +// and the cursor lands again, however you left. Phones keep their keyboard +// down until a tap. function focusSendField() { if (matchMedia('(pointer: coarse)').matches) return; const pane = document.querySelector('[data-send-pane]'); @@ -4737,10 +4738,13 @@ function focusSendField() { 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; + if (!field || field._autoFocused) return; + field._autoFocused = true; + // Only typing is protected: a clicked button (the Send tab itself keeps the + // focus a mouse click gave it) or a link has nothing to lose. const a = document.activeElement; - if (a && a !== document.body && !(amt && a.classList && a.classList.contains('send-dest'))) return; + const typing = a && a !== document.body && (a.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)); + if (typing && !(amt && a.classList.contains('send-dest'))) return; field.focus(); } @@ -4758,7 +4762,6 @@ 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(focusSendField); |
