fix(web): keep collapsed files closed in loaded windows and ignore held keys
- commit
- e235ca3cdc03f9a93d2b9c1f7062aea0570a3864
- author
- brice · · 2026-10-20 08:12 UTC
- parent
- 6d4e2aa
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +6 -2
M internal/adapters/web/static/js/lazy.js +6 -2
| @@ -59,8 +59,10 @@ window.ermiteLazy = (() => { | |||
| 59 | 59 | for (const f of [...t.content.querySelectorAll('details[data-file]')]) { | |
| 60 | 60 | const old = document.getElementById(f.id); | |
| 61 | 61 | if (!old || !old.querySelector('.dlazy')) continue; | |
| 62 | - | // A collapsed file opens once loaded; a file of a window keeps the fold. | |
| 63 | - | f.open = old.querySelector('.dlazy[data-manual]') ? true : old.open; | |
| 62 | + | // A file still collapsed stays closed; a collapsed file opens once | |
| 63 | + | // loaded; a file of a window keeps the fold. | |
| 64 | + | f.open = f.querySelector('.dlazy[data-manual]') ? false | |
| 65 | + | : old.querySelector('.dlazy[data-manual]') ? true : old.open; | |
| 64 | 66 | for (const p of $$('.dlazy', old)) lazyIO?.unobserve(p); | |
| 65 | 67 | old.replaceWith(f); | |
| 66 | 68 | window.htmx?.process(f); | |
| @@ -126,6 +128,8 @@ window.ermiteLazy = (() => { | |||
| 126 | 128 | // Enter makes the browser click a link by itself; Space does not. Both are | |
| 127 | 129 | // handled here, once (a fragment is fetched once). | |
| 128 | 130 | function onKey(e) { | |
| 131 | + | // A held key repeats: after the load, focus is on a line link. | |
| 132 | + | if (e.repeat) return false; | |
| 129 | 133 | if ((e.key !== 'Enter' && e.key !== ' ') || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return false; | |
| 130 | 134 | const a = manualLink(e.target); | |
| 131 | 135 | if (!a) return false; | |
| @@ -59,8 +59,10 @@ window.ermiteLazy = (() => { | |||||
| 59 | for (const f of [...t.content.querySelectorAll('details[data-file]')]) { | 59 | for (const f of [...t.content.querySelectorAll('details[data-file]')]) { | ||
| 60 | const old = document.getElementById(f.id); | 60 | const old = document.getElementById(f.id); | ||
| 61 | if (!old || !old.querySelector('.dlazy')) continue; | 61 | if (!old || !old.querySelector('.dlazy')) continue; | ||
| 62 | - | // A collapsed file opens once loaded; a file of a window keeps the fold. | 62 | + | // A file still collapsed stays closed; a collapsed file opens once |
| 63 | - | f.open = old.querySelector('.dlazy[data-manual]') ? true : old.open; | 63 | + | // loaded; a file of a window keeps the fold. |
| 64 | + | f.open = f.querySelector('.dlazy[data-manual]') ? false | |||
| 65 | + | : old.querySelector('.dlazy[data-manual]') ? true : old.open; | |||
| 64 | for (const p of $$('.dlazy', old)) lazyIO?.unobserve(p); | 66 | for (const p of $$('.dlazy', old)) lazyIO?.unobserve(p); | ||
| 65 | old.replaceWith(f); | 67 | old.replaceWith(f); | ||
| 66 | window.htmx?.process(f); | 68 | window.htmx?.process(f); | ||
| @@ -126,6 +128,8 @@ window.ermiteLazy = (() => { | |||||
| 126 | // Enter makes the browser click a link by itself; Space does not. Both are | 128 | // Enter makes the browser click a link by itself; Space does not. Both are | ||
| 127 | // handled here, once (a fragment is fetched once). | 129 | // handled here, once (a fragment is fetched once). | ||
| 128 | function onKey(e) { | 130 | function onKey(e) { | ||
| 131 | + | // A held key repeats: after the load, focus is on a line link. | |||
| 132 | + | if (e.repeat) return false; | |||
| 129 | if ((e.key !== 'Enter' && e.key !== ' ') || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return false; | 133 | if ((e.key !== 'Enter' && e.key !== ' ') || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return false; | ||
| 130 | const a = manualLink(e.target); | 134 | const a = manualLink(e.target); | ||
| 131 | if (!a) return false; | 135 | if (!a) return false; | ||