fix(web): keep MR panels open on refresh, expose one option per palette result, clear finder status
- commit
- 1f47bc8381cfffcf072a32c5ca85ad6228b5cdb0
- author
- brice · · 2026-10-22 08:00 UTC
- parent
- 21b3830
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
9 files · +123 -27
M internal/adapters/web/accessibility_test.go +10 -1
| @@ -34,11 +34,20 @@ func TestPaletteAccessibilityWithoutNavigationItems(t *testing.T) { | |||
| 34 | 34 | assert.Contains(t, html, `aria-expanded="true"`) | |
| 35 | 35 | assert.Contains(t, html, `aria-activedescendant="cmd-o0"`) | |
| 36 | 36 | assert.Contains(t, html, `id="cmd-o0" role="option" aria-selected="true" data-cursor`) | |
| 37 | - | assert.Contains(t, html, `<a role="presentation" href="#" data-fire="keys" tabindex="-1">`) | |
| 37 | + | assert.Contains(t, html, `<a role="presentation" data-fire="keys">`) | |
| 38 | 38 | assert.Contains(t, html, `aria-label="Close (esc)"`) | |
| 39 | + | assert.NotContains(t, html, ` href=`) | |
| 40 | + | assert.NotContains(t, html, `tabindex="-1"`) | |
| 39 | 41 | } | |
| 40 | 42 | ||
| 41 | 43 | func TestFinderStatusOutsideHiddenResults(t *testing.T) { | |
| 42 | 44 | html := renderToString(t, Tree(Layout{}, TreePage{})) | |
| 43 | 45 | assert.Contains(t, html, `<p id="finder-status" class="dim" role="status"></p><div id="finder" class="tree-card" hidden>`) | |
| 44 | 46 | } | |
| 47 | + | ||
| 48 | + | func TestPaletteNavigationOptionsAccessibility(t *testing.T) { | |
| 49 | + | html := renderToString(t, OverlayCmd([]CmdItem{{Kind: "section", Label: "Files", Href: "/files"}})) | |
| 50 | + | assert.Contains(t, html, `<a role="presentation" data-href="/files">`) | |
| 51 | + | assert.NotContains(t, html, ` href=`) | |
| 52 | + | assert.NotContains(t, html, `tabindex="-1"`) | |
| 53 | + | } | |
| @@ -34,11 +34,20 @@ func TestPaletteAccessibilityWithoutNavigationItems(t *testing.T) { | |||||
| 34 | assert.Contains(t, html, `aria-expanded="true"`) | 34 | assert.Contains(t, html, `aria-expanded="true"`) | ||
| 35 | assert.Contains(t, html, `aria-activedescendant="cmd-o0"`) | 35 | assert.Contains(t, html, `aria-activedescendant="cmd-o0"`) | ||
| 36 | assert.Contains(t, html, `id="cmd-o0" role="option" aria-selected="true" data-cursor`) | 36 | assert.Contains(t, html, `id="cmd-o0" role="option" aria-selected="true" data-cursor`) | ||
| 37 | - | assert.Contains(t, html, `<a role="presentation" href="#" data-fire="keys" tabindex="-1">`) | 37 | + | assert.Contains(t, html, `<a role="presentation" data-fire="keys">`) |
| 38 | assert.Contains(t, html, `aria-label="Close (esc)"`) | 38 | assert.Contains(t, html, `aria-label="Close (esc)"`) | ||
| 39 | + | assert.NotContains(t, html, ` href=`) | |||
| 40 | + | assert.NotContains(t, html, `tabindex="-1"`) | |||
| 39 | } | 41 | } | ||
| 40 | 42 | ||||
| 41 | func TestFinderStatusOutsideHiddenResults(t *testing.T) { | 43 | func TestFinderStatusOutsideHiddenResults(t *testing.T) { | ||
| 42 | html := renderToString(t, Tree(Layout{}, TreePage{})) | 44 | html := renderToString(t, Tree(Layout{}, TreePage{})) | ||
| 43 | assert.Contains(t, html, `<p id="finder-status" class="dim" role="status"></p><div id="finder" class="tree-card" hidden>`) | 45 | assert.Contains(t, html, `<p id="finder-status" class="dim" role="status"></p><div id="finder" class="tree-card" hidden>`) | ||
| 44 | } | 46 | } | ||
| 47 | + | ||||
| 48 | + | func TestPaletteNavigationOptionsAccessibility(t *testing.T) { | |||
| 49 | + | html := renderToString(t, OverlayCmd([]CmdItem{{Kind: "section", Label: "Files", Href: "/files"}})) | |||
| 50 | + | assert.Contains(t, html, `<a role="presentation" data-href="/files">`) | |||
| 51 | + | assert.NotContains(t, html, ` href=`) | |||
| 52 | + | assert.NotContains(t, html, `tabindex="-1"`) | |||
| 53 | + | } | |||
M internal/adapters/web/jstest/a11y.test.mjs +45 -1
| @@ -83,7 +83,7 @@ function keydown(target, key, elementHandler, extra = {}) { | |||
| 83 | 83 | // ---- the palette -------------------------------------------------------- | |
| 84 | 84 | ||
| 85 | 85 | function palette() { | |
| 86 | - | const li = (k, label) => el('li', { attrs: { 'data-k': k } }, el('a', { attrs: { href: '/' + label } })); | |
| 86 | + | const li = (k, label) => el('li', { attrs: { 'data-k': k } }, el('a', { attrs: { 'data-href': '/' + label, role: 'presentation' } })); | |
| 87 | 87 | const items = [li('go home', 'home'), li('section files', 'files'), li('branch main', 'main')]; | |
| 88 | 88 | items[0].setAttribute('data-cursor', ''); | |
| 89 | 89 | const input = el('input', { id: 'cmd-q', attrs: { role: 'combobox', 'aria-controls': 'cmd-list' } }); | |
| @@ -137,6 +137,8 @@ test('the palette: the file hits that arrive later get ids, roles and the active | |||
| 137 | 137 | assert.ok(hits.length > 0, 'a file hit came'); | |
| 138 | 138 | for (const h of hits) { | |
| 139 | 139 | assert.equal(h.getAttribute('role'), 'option'); | |
| 140 | + | assert.equal(h.querySelector('a[href]'), null); | |
| 141 | + | assert.equal(h.querySelector('a').hasAttribute('tabindex'), false); | |
| 140 | 142 | assert.ok(h.id); | |
| 141 | 143 | } | |
| 142 | 144 | assert.equal(p.list.children.length, new Set(p.list.children.map((i) => i.id)).size, 'ids stay unique'); | |
| @@ -173,6 +175,7 @@ test('Escape in the finder clears the query, keeps the focus in the field and do | |||
| 173 | 175 | f.q.closest = () => f.q; // the global handler sees a field being typed in | |
| 174 | 176 | const e = keydown(f.q, 'Escape', (ev) => F.key(f.q, ev)); | |
| 175 | 177 | assert.equal(f.q.value, ''); | |
| 178 | + | assert.equal(doc.getElementById('finder-status').textContent, ''); | |
| 176 | 179 | assert.equal(e.stopped, true); | |
| 177 | 180 | assert.equal(e.prevented, true); | |
| 178 | 181 | assert.equal(blurred, false, 'the field keeps the focus'); | |
| @@ -415,3 +418,44 @@ test('dialog restores its row opener on close, but not over a replacement dialog | |||
| 415 | 418 | doc.querySelectorAll = all; | |
| 416 | 419 | doc.querySelector = one; | |
| 417 | 420 | }); | |
| 421 | + | ||
| 422 | + | ||
| 423 | + | test('listbox result wrappers have no links; Enter and delegated clicks navigate', async () => { | |
| 424 | + | doc.querySelector = query.one; | |
| 425 | + | doc.querySelectorAll = query.all; | |
| 426 | + | const assigned = []; | |
| 427 | + | location.assign = (href) => assigned.push(href); | |
| 428 | + | const activate = (anchor) => { | |
| 429 | + | const e = { target: anchor, button: 0, preventDefault() {} }; | |
| 430 | + | listeners.click.find((fn) => fn.toString().includes('location.assign'))(e); | |
| 431 | + | }; | |
| 432 | + | const p = palette(); | |
| 433 | + | p.list.setAttribute('role', 'listbox'); | |
| 434 | + | window.ermiteCmd.sync(); | |
| 435 | + | for (const item of p.items) assert.equal(item.querySelector('a[href]'), null); | |
| 436 | + | const a = p.items[0].querySelector('a'); | |
| 437 | + | a.click = () => activate(a); | |
| 438 | + | window.ermite.cmdKey({ key: 'Enter', preventDefault() {} }); | |
| 439 | + | assert.deepEqual(assigned, ['/home']); | |
| 440 | + | activate(p.items[1].querySelector('a')); | |
| 441 | + | assert.deepEqual(assigned, ['/home', '/files']); | |
| 442 | + | ||
| 443 | + | const f = finder(); | |
| 444 | + | f.list.setAttribute('role', 'listbox'); | |
| 445 | + | f.q.value = 'main'; | |
| 446 | + | F.input(f.q); | |
| 447 | + | flushFrames(); | |
| 448 | + | await settle(); | |
| 449 | + | assert.equal(f.list.querySelector('a[href]'), null); | |
| 450 | + | const hit = f.list.children[0].querySelector('a'); | |
| 451 | + | assert.equal(hit.hasAttribute('tabindex'), false); | |
| 452 | + | hit.click = () => activate(hit); | |
| 453 | + | F.key(f.q, { key: 'Enter', preventDefault() {} }); | |
| 454 | + | assert.equal(assigned.at(-1), hit.dataset.href); | |
| 455 | + | activate(hit); | |
| 456 | + | assert.equal(assigned.at(-1), hit.dataset.href); | |
| 457 | + | assert.notEqual(doc.getElementById('finder-status').textContent, ''); | |
| 458 | + | f.q.value = ''; | |
| 459 | + | F.input(f.q); | |
| 460 | + | assert.equal(doc.getElementById('finder-status').textContent, ''); | |
| 461 | + | }); | |
| @@ -83,7 +83,7 @@ function keydown(target, key, elementHandler, extra = {}) { | |||||
| 83 | // ---- the palette -------------------------------------------------------- | 83 | // ---- the palette -------------------------------------------------------- | ||
| 84 | 84 | ||||
| 85 | function palette() { | 85 | function palette() { | ||
| 86 | - | const li = (k, label) => el('li', { attrs: { 'data-k': k } }, el('a', { attrs: { href: '/' + label } })); | 86 | + | const li = (k, label) => el('li', { attrs: { 'data-k': k } }, el('a', { attrs: { 'data-href': '/' + label, role: 'presentation' } })); |
| 87 | const items = [li('go home', 'home'), li('section files', 'files'), li('branch main', 'main')]; | 87 | const items = [li('go home', 'home'), li('section files', 'files'), li('branch main', 'main')]; | ||
| 88 | items[0].setAttribute('data-cursor', ''); | 88 | items[0].setAttribute('data-cursor', ''); | ||
| 89 | const input = el('input', { id: 'cmd-q', attrs: { role: 'combobox', 'aria-controls': 'cmd-list' } }); | 89 | const input = el('input', { id: 'cmd-q', attrs: { role: 'combobox', 'aria-controls': 'cmd-list' } }); | ||
| @@ -137,6 +137,8 @@ test('the palette: the file hits that arrive later get ids, roles and the active | |||||
| 137 | assert.ok(hits.length > 0, 'a file hit came'); | 137 | assert.ok(hits.length > 0, 'a file hit came'); | ||
| 138 | for (const h of hits) { | 138 | for (const h of hits) { | ||
| 139 | assert.equal(h.getAttribute('role'), 'option'); | 139 | assert.equal(h.getAttribute('role'), 'option'); | ||
| 140 | + | assert.equal(h.querySelector('a[href]'), null); | |||
| 141 | + | assert.equal(h.querySelector('a').hasAttribute('tabindex'), false); | |||
| 140 | assert.ok(h.id); | 142 | assert.ok(h.id); | ||
| 141 | } | 143 | } | ||
| 142 | assert.equal(p.list.children.length, new Set(p.list.children.map((i) => i.id)).size, 'ids stay unique'); | 144 | assert.equal(p.list.children.length, new Set(p.list.children.map((i) => i.id)).size, 'ids stay unique'); | ||
| @@ -173,6 +175,7 @@ test('Escape in the finder clears the query, keeps the focus in the field and do | |||||
| 173 | f.q.closest = () => f.q; // the global handler sees a field being typed in | 175 | f.q.closest = () => f.q; // the global handler sees a field being typed in | ||
| 174 | const e = keydown(f.q, 'Escape', (ev) => F.key(f.q, ev)); | 176 | const e = keydown(f.q, 'Escape', (ev) => F.key(f.q, ev)); | ||
| 175 | assert.equal(f.q.value, ''); | 177 | assert.equal(f.q.value, ''); | ||
| 178 | + | assert.equal(doc.getElementById('finder-status').textContent, ''); | |||
| 176 | assert.equal(e.stopped, true); | 179 | assert.equal(e.stopped, true); | ||
| 177 | assert.equal(e.prevented, true); | 180 | assert.equal(e.prevented, true); | ||
| 178 | assert.equal(blurred, false, 'the field keeps the focus'); | 181 | assert.equal(blurred, false, 'the field keeps the focus'); | ||
| @@ -415,3 +418,44 @@ test('dialog restores its row opener on close, but not over a replacement dialog | |||||
| 415 | doc.querySelectorAll = all; | 418 | doc.querySelectorAll = all; | ||
| 416 | doc.querySelector = one; | 419 | doc.querySelector = one; | ||
| 417 | }); | 420 | }); | ||
| 421 | + | ||||
| 422 | + | ||||
| 423 | + | test('listbox result wrappers have no links; Enter and delegated clicks navigate', async () => { | |||
| 424 | + | doc.querySelector = query.one; | |||
| 425 | + | doc.querySelectorAll = query.all; | |||
| 426 | + | const assigned = []; | |||
| 427 | + | location.assign = (href) => assigned.push(href); | |||
| 428 | + | const activate = (anchor) => { | |||
| 429 | + | const e = { target: anchor, button: 0, preventDefault() {} }; | |||
| 430 | + | listeners.click.find((fn) => fn.toString().includes('location.assign'))(e); | |||
| 431 | + | }; | |||
| 432 | + | const p = palette(); | |||
| 433 | + | p.list.setAttribute('role', 'listbox'); | |||
| 434 | + | window.ermiteCmd.sync(); | |||
| 435 | + | for (const item of p.items) assert.equal(item.querySelector('a[href]'), null); | |||
| 436 | + | const a = p.items[0].querySelector('a'); | |||
| 437 | + | a.click = () => activate(a); | |||
| 438 | + | window.ermite.cmdKey({ key: 'Enter', preventDefault() {} }); | |||
| 439 | + | assert.deepEqual(assigned, ['/home']); | |||
| 440 | + | activate(p.items[1].querySelector('a')); | |||
| 441 | + | assert.deepEqual(assigned, ['/home', '/files']); | |||
| 442 | + | ||||
| 443 | + | const f = finder(); | |||
| 444 | + | f.list.setAttribute('role', 'listbox'); | |||
| 445 | + | f.q.value = 'main'; | |||
| 446 | + | F.input(f.q); | |||
| 447 | + | flushFrames(); | |||
| 448 | + | await settle(); | |||
| 449 | + | assert.equal(f.list.querySelector('a[href]'), null); | |||
| 450 | + | const hit = f.list.children[0].querySelector('a'); | |||
| 451 | + | assert.equal(hit.hasAttribute('tabindex'), false); | |||
| 452 | + | hit.click = () => activate(hit); | |||
| 453 | + | F.key(f.q, { key: 'Enter', preventDefault() {} }); | |||
| 454 | + | assert.equal(assigned.at(-1), hit.dataset.href); | |||
| 455 | + | activate(hit); | |||
| 456 | + | assert.equal(assigned.at(-1), hit.dataset.href); | |||
| 457 | + | assert.notEqual(doc.getElementById('finder-status').textContent, ''); | |||
| 458 | + | f.q.value = ''; | |||
| 459 | + | F.input(f.q); | |||
| 460 | + | assert.equal(doc.getElementById('finder-status').textContent, ''); | |||
| 461 | + | }); | |||
M internal/adapters/web/jstest/finder.test.mjs +9 -8
| @@ -53,7 +53,7 @@ const key = (k, extra = {}) => { | |||
| 53 | 53 | return e; | |
| 54 | 54 | }; | |
| 55 | 55 | const status = () => document.getElementById('finder-status').textContent; | |
| 56 | - | const hrefs = (list) => list.children.map((li) => li.querySelector('a').href); | |
| 56 | + | const hrefs = (list) => list.children.map((li) => li.querySelector('a').dataset.href); | |
| 57 | 57 | ||
| 58 | 58 | test('Enter before the results opens the top hit once they come', async () => { | |
| 59 | 59 | const p = page(); | |
| @@ -66,8 +66,8 @@ test('Enter before the results opens the top hit once they come', async () => { | |||
| 66 | 66 | await settle(); | |
| 67 | 67 | assert.equal(p.finderList.children.length > 0, true); | |
| 68 | 68 | assert.equal(dom.clicked.length, 1); | |
| 69 | - | assert.equal(dom.clicked[0].href, hrefs(p.finderList)[0]); | |
| 70 | - | assert.match(dom.clicked[0].href, /^\/blob\/main\/.*tree/); | |
| 69 | + | assert.equal(dom.clicked[0].dataset.href, hrefs(p.finderList)[0]); | |
| 70 | + | assert.match(dom.clicked[0].dataset.href, /^\/blob\/main\/.*tree/); | |
| 71 | 71 | assert.equal(fetches, 1); | |
| 72 | 72 | }); | |
| 73 | 73 | ||
| @@ -112,7 +112,7 @@ test('Enter on current results opens the cursor row, whichever way the cursor mo | |||
| 112 | 112 | assert.equal(items[2].getAttribute('aria-selected'), 'true'); | |
| 113 | 113 | assert.equal(items[0].getAttribute('aria-selected'), 'false'); | |
| 114 | 114 | assert.equal(p.q.getAttribute('aria-activedescendant'), items[2].id); | |
| 115 | - | assert.equal(dom.clicked[0].href, items[2].querySelector('a').href); | |
| 115 | + | assert.equal(dom.clicked[0].dataset.href, items[2].querySelector('a').dataset.href); | |
| 116 | 116 | // The arrows move from there. | |
| 117 | 117 | F.key(p.q, key('ArrowUp')); | |
| 118 | 118 | assert.equal(p.q.getAttribute('aria-activedescendant'), items[1].id); | |
| @@ -179,13 +179,14 @@ test('the palette lists the file hits under its entries', async () => { | |||
| 179 | 179 | const hits = p.cmdList.children.filter((li) => li.className === 'finder-hit'); | |
| 180 | 180 | assert.equal(hits.length, 4); | |
| 181 | 181 | assert.equal(p.cmdList.children[0].className, 'entry', 'the entries stay first'); | |
| 182 | - | assert.deepEqual(hits.map((li) => li.querySelector('a').href).sort(), [ | |
| 182 | + | assert.deepEqual(hits.map((li) => li.querySelector('a').dataset.href).sort(), [ | |
| 183 | 183 | '/blob/main/docs/web/tree-view.md', | |
| 184 | 184 | '/blob/main/internal/adapters/web/tree.go', | |
| 185 | 185 | '/blob/main/internal/adapters/web/tree.templ', | |
| 186 | 186 | '/blob/main/src/treehouse.txt', | |
| 187 | 187 | ]); | |
| 188 | - | assert.equal(hits[0].querySelector('a').tabIndex, -1); | |
| 188 | + | assert.equal(hits[0].querySelector('a').hasAttribute('href'), false); | |
| 189 | + | assert.equal(hits[0].querySelector('a').hasAttribute('tabindex'), false); | |
| 189 | 190 | assert.equal(hits[0].querySelector('.k').textContent, 'file'); | |
| 190 | 191 | assert.equal(p.cmdList.children.filter((li) => li.hasAttribute('data-cursor')).length, 1, 'one cursor'); | |
| 191 | 192 | ||
| @@ -213,7 +214,7 @@ test('Enter typed before the frame of the query runs opens the top hit', async ( | |||
| 213 | 214 | assert.equal(dom.clicked.length, 0, 'nothing to open before the frame'); | |
| 214 | 215 | flushFrames(); | |
| 215 | 216 | await settle(); | |
| 216 | - | assert.deepEqual(dom.clicked.map((a) => a.href), ['/blob/main/cmd/ermite/main.go']); | |
| 217 | + | assert.deepEqual(dom.clicked.map((a) => a.dataset.href), ['/blob/main/cmd/ermite/main.go']); | |
| 217 | 218 | } finally { | |
| 218 | 219 | dom.holdFrames = false; | |
| 219 | 220 | } | |
| @@ -257,7 +258,7 @@ test('the palette drops the results of a query that is stale', async () => { | |||
| 257 | 258 | p.cmdQ.value = 'readme'; // typed before the search of "tree" finished | |
| 258 | 259 | F.palette(p.cmdQ); | |
| 259 | 260 | await settle(); | |
| 260 | - | const got = p.cmdList.children.filter((li) => li.className === 'finder-hit').map((li) => li.querySelector('a').href); | |
| 261 | + | const got = p.cmdList.children.filter((li) => li.className === 'finder-hit').map((li) => li.querySelector('a').dataset.href); | |
| 261 | 262 | assert.deepEqual(got, ['/blob/main/README.md']); | |
| 262 | 263 | ||
| 263 | 264 | // A field changed without a new call: the pending search is dropped. | |
| @@ -53,7 +53,7 @@ const key = (k, extra = {}) => { | |||||
| 53 | return e; | 53 | return e; | ||
| 54 | }; | 54 | }; | ||
| 55 | const status = () => document.getElementById('finder-status').textContent; | 55 | const status = () => document.getElementById('finder-status').textContent; | ||
| 56 | - | const hrefs = (list) => list.children.map((li) => li.querySelector('a').href); | 56 | + | const hrefs = (list) => list.children.map((li) => li.querySelector('a').dataset.href); |
| 57 | 57 | ||||
| 58 | test('Enter before the results opens the top hit once they come', async () => { | 58 | test('Enter before the results opens the top hit once they come', async () => { | ||
| 59 | const p = page(); | 59 | const p = page(); | ||
| @@ -66,8 +66,8 @@ test('Enter before the results opens the top hit once they come', async () => { | |||||
| 66 | await settle(); | 66 | await settle(); | ||
| 67 | assert.equal(p.finderList.children.length > 0, true); | 67 | assert.equal(p.finderList.children.length > 0, true); | ||
| 68 | assert.equal(dom.clicked.length, 1); | 68 | assert.equal(dom.clicked.length, 1); | ||
| 69 | - | assert.equal(dom.clicked[0].href, hrefs(p.finderList)[0]); | 69 | + | assert.equal(dom.clicked[0].dataset.href, hrefs(p.finderList)[0]); |
| 70 | - | assert.match(dom.clicked[0].href, /^\/blob\/main\/.*tree/); | 70 | + | assert.match(dom.clicked[0].dataset.href, /^\/blob\/main\/.*tree/); |
| 71 | assert.equal(fetches, 1); | 71 | assert.equal(fetches, 1); | ||
| 72 | }); | 72 | }); | ||
| 73 | 73 | ||||
| @@ -112,7 +112,7 @@ test('Enter on current results opens the cursor row, whichever way the cursor mo | |||||
| 112 | assert.equal(items[2].getAttribute('aria-selected'), 'true'); | 112 | assert.equal(items[2].getAttribute('aria-selected'), 'true'); | ||
| 113 | assert.equal(items[0].getAttribute('aria-selected'), 'false'); | 113 | assert.equal(items[0].getAttribute('aria-selected'), 'false'); | ||
| 114 | assert.equal(p.q.getAttribute('aria-activedescendant'), items[2].id); | 114 | assert.equal(p.q.getAttribute('aria-activedescendant'), items[2].id); | ||
| 115 | - | assert.equal(dom.clicked[0].href, items[2].querySelector('a').href); | 115 | + | assert.equal(dom.clicked[0].dataset.href, items[2].querySelector('a').dataset.href); |
| 116 | // The arrows move from there. | 116 | // The arrows move from there. | ||
| 117 | F.key(p.q, key('ArrowUp')); | 117 | F.key(p.q, key('ArrowUp')); | ||
| 118 | assert.equal(p.q.getAttribute('aria-activedescendant'), items[1].id); | 118 | assert.equal(p.q.getAttribute('aria-activedescendant'), items[1].id); | ||
| @@ -179,13 +179,14 @@ test('the palette lists the file hits under its entries', async () => { | |||||
| 179 | const hits = p.cmdList.children.filter((li) => li.className === 'finder-hit'); | 179 | const hits = p.cmdList.children.filter((li) => li.className === 'finder-hit'); | ||
| 180 | assert.equal(hits.length, 4); | 180 | assert.equal(hits.length, 4); | ||
| 181 | assert.equal(p.cmdList.children[0].className, 'entry', 'the entries stay first'); | 181 | assert.equal(p.cmdList.children[0].className, 'entry', 'the entries stay first'); | ||
| 182 | - | assert.deepEqual(hits.map((li) => li.querySelector('a').href).sort(), [ | 182 | + | assert.deepEqual(hits.map((li) => li.querySelector('a').dataset.href).sort(), [ |
| 183 | '/blob/main/docs/web/tree-view.md', | 183 | '/blob/main/docs/web/tree-view.md', | ||
| 184 | '/blob/main/internal/adapters/web/tree.go', | 184 | '/blob/main/internal/adapters/web/tree.go', | ||
| 185 | '/blob/main/internal/adapters/web/tree.templ', | 185 | '/blob/main/internal/adapters/web/tree.templ', | ||
| 186 | '/blob/main/src/treehouse.txt', | 186 | '/blob/main/src/treehouse.txt', | ||
| 187 | ]); | 187 | ]); | ||
| 188 | - | assert.equal(hits[0].querySelector('a').tabIndex, -1); | 188 | + | assert.equal(hits[0].querySelector('a').hasAttribute('href'), false); |
| 189 | + | assert.equal(hits[0].querySelector('a').hasAttribute('tabindex'), false); | |||
| 189 | assert.equal(hits[0].querySelector('.k').textContent, 'file'); | 190 | assert.equal(hits[0].querySelector('.k').textContent, 'file'); | ||
| 190 | assert.equal(p.cmdList.children.filter((li) => li.hasAttribute('data-cursor')).length, 1, 'one cursor'); | 191 | assert.equal(p.cmdList.children.filter((li) => li.hasAttribute('data-cursor')).length, 1, 'one cursor'); | ||
| 191 | 192 | ||||
| @@ -213,7 +214,7 @@ test('Enter typed before the frame of the query runs opens the top hit', async ( | |||||
| 213 | assert.equal(dom.clicked.length, 0, 'nothing to open before the frame'); | 214 | assert.equal(dom.clicked.length, 0, 'nothing to open before the frame'); | ||
| 214 | flushFrames(); | 215 | flushFrames(); | ||
| 215 | await settle(); | 216 | await settle(); | ||
| 216 | - | assert.deepEqual(dom.clicked.map((a) => a.href), ['/blob/main/cmd/ermite/main.go']); | 217 | + | assert.deepEqual(dom.clicked.map((a) => a.dataset.href), ['/blob/main/cmd/ermite/main.go']); |
| 217 | } finally { | 218 | } finally { | ||
| 218 | dom.holdFrames = false; | 219 | dom.holdFrames = false; | ||
| 219 | } | 220 | } | ||
| @@ -257,7 +258,7 @@ test('the palette drops the results of a query that is stale', async () => { | |||||
| 257 | p.cmdQ.value = 'readme'; // typed before the search of "tree" finished | 258 | p.cmdQ.value = 'readme'; // typed before the search of "tree" finished | ||
| 258 | F.palette(p.cmdQ); | 259 | F.palette(p.cmdQ); | ||
| 259 | await settle(); | 260 | await settle(); | ||
| 260 | - | const got = p.cmdList.children.filter((li) => li.className === 'finder-hit').map((li) => li.querySelector('a').href); | 261 | + | const got = p.cmdList.children.filter((li) => li.className === 'finder-hit').map((li) => li.querySelector('a').dataset.href); |
| 261 | assert.deepEqual(got, ['/blob/main/README.md']); | 262 | assert.deepEqual(got, ['/blob/main/README.md']); | ||
| 262 | 263 | ||||
| 263 | // A field changed without a new call: the pending search is dropped. | 264 | // A field changed without a new call: the pending search is dropped. | ||
M internal/adapters/web/jstest/mr.test.mjs +33 -1
| @@ -106,7 +106,7 @@ function footerHarness(extra = {}) { | |||
| 106 | 106 | const nav = node('tabs'); nav.querySelectorAll = () => tabs; | |
| 107 | 107 | const listeners = {}, replaced = []; | |
| 108 | 108 | globalThis.document = { querySelector: (s) => s === '.mr-footer' ? footer : s === '[data-mr-tabs]' ? nav : s === '#mr-ck' ? extra.summary ?? null : null, | |
| 109 | - | querySelectorAll: (s) => s === '[data-mr-tabs] a' ? tabs : [], addEventListener(k, v) { listeners[k] = v; } }; | |
| 109 | + | querySelectorAll: (s) => s === '[data-mr-tabs] button' ? tabs : [], addEventListener(k, v) { listeners[k] = v; } }; | |
| 110 | 110 | globalThis.location = { hash: '', pathname: '/demo/merge-requests/1', search: '?x=1' }; | |
| 111 | 111 | globalThis.addEventListener = (k, v) => { listeners[k] = v; }; | |
| 112 | 112 | globalThis.history = { replaceState: (...args) => replaced.push(args) }; | |
| @@ -531,3 +531,35 @@ test('intercepted Cancel resets the entire comment form', () => { | |||
| 531 | 531 | assert.equal(window.ermiteMR.hasDraft(), false); | |
| 532 | 532 | } finally { Object.assign(globalThis, saved); c.restore(); } | |
| 533 | 533 | }); | |
| 534 | + | ||
| 535 | + | ||
| 536 | + | test('live refresh preserves the open button panel even when the hash points elsewhere', async () => { | |
| 537 | + | const { readFileSync } = await import('node:fs'); | |
| 538 | + | const src = readFileSync(new URL('../static/js/mr.js', import.meta.url), 'utf8'); | |
| 539 | + | const start = src.indexOf(' async function refreshPage(page)'); | |
| 540 | + | const end = src.indexOf(' function refreshNotice', start); | |
| 541 | + | const { el, installDom } = await import('./dom.mjs'); | |
| 542 | + | const saved = globalThis.document; | |
| 543 | + | const h = footerHarness(); | |
| 544 | + | try { | |
| 545 | + | window.ermiteMR.panels(); | |
| 546 | + | h.tabs[1].events.click({ preventDefault() {} }); | |
| 547 | + | location.hash = '#f99'; | |
| 548 | + | const doc = installDom(); | |
| 549 | + | Object.defineProperty(doc, 'activeElement', { get: () => null }); | |
| 550 | + | const diffs = el('div'); | |
| 551 | + | diffs.dataset.diff = 'unified'; | |
| 552 | + | const fresh = el('footer', {}, el('section', { attrs: { 'data-mr-panel': '' } }), el('section', { attrs: { 'data-mr-panel': '' } })); | |
| 553 | + | const page = { body: { dataset: {} } }; | |
| 554 | + | const $ = (s, root) => s === '#diffs' ? diffs : s === '.mr-footer' ? (root === page ? fresh : h.footer) : el('div'); | |
| 555 | + | const $$ = (s, root) => s === '[data-mr-tabs] button' ? h.tabs : s === '[data-mr-panel]' ? fresh.children : []; | |
| 556 | + | let selected; | |
| 557 | + | const lazy = { reset() {}, watch() {} }; | |
| 558 | + | const refresh = new Function('$', '$$', 'scrollAnchor', 'hasDraft', 'replaceRegion', 'panels', 'watchBar', 'foldFiles', 'touchComments', 'restoreAnchor', 'window', 'document', | |
| 559 | + | 'let revealGen = 0; ' + src.slice(start, end) + '; return refreshPage;')( | |
| 560 | + | $, $$, () => ({}), () => false, async () => {}, (i) => { selected = i; }, () => {}, () => {}, () => {}, () => {}, { ermiteLazy: lazy }, doc); | |
| 561 | + | await refresh(page); | |
| 562 | + | assert.equal(selected, 1); | |
| 563 | + | assert.deepEqual(fresh.children.map((p) => p.hidden), [true, false]); | |
| 564 | + | } finally { h.restore(); globalThis.document = saved; } | |
| 565 | + | }); | |
| @@ -106,7 +106,7 @@ function footerHarness(extra = {}) { | |||||
| 106 | const nav = node('tabs'); nav.querySelectorAll = () => tabs; | 106 | const nav = node('tabs'); nav.querySelectorAll = () => tabs; | ||
| 107 | const listeners = {}, replaced = []; | 107 | const listeners = {}, replaced = []; | ||
| 108 | globalThis.document = { querySelector: (s) => s === '.mr-footer' ? footer : s === '[data-mr-tabs]' ? nav : s === '#mr-ck' ? extra.summary ?? null : null, | 108 | globalThis.document = { querySelector: (s) => s === '.mr-footer' ? footer : s === '[data-mr-tabs]' ? nav : s === '#mr-ck' ? extra.summary ?? null : null, | ||
| 109 | - | querySelectorAll: (s) => s === '[data-mr-tabs] a' ? tabs : [], addEventListener(k, v) { listeners[k] = v; } }; | 109 | + | querySelectorAll: (s) => s === '[data-mr-tabs] button' ? tabs : [], addEventListener(k, v) { listeners[k] = v; } }; |
| 110 | globalThis.location = { hash: '', pathname: '/demo/merge-requests/1', search: '?x=1' }; | 110 | globalThis.location = { hash: '', pathname: '/demo/merge-requests/1', search: '?x=1' }; | ||
| 111 | globalThis.addEventListener = (k, v) => { listeners[k] = v; }; | 111 | globalThis.addEventListener = (k, v) => { listeners[k] = v; }; | ||
| 112 | globalThis.history = { replaceState: (...args) => replaced.push(args) }; | 112 | globalThis.history = { replaceState: (...args) => replaced.push(args) }; | ||
| @@ -531,3 +531,35 @@ test('intercepted Cancel resets the entire comment form', () => { | |||||
| 531 | assert.equal(window.ermiteMR.hasDraft(), false); | 531 | assert.equal(window.ermiteMR.hasDraft(), false); | ||
| 532 | } finally { Object.assign(globalThis, saved); c.restore(); } | 532 | } finally { Object.assign(globalThis, saved); c.restore(); } | ||
| 533 | }); | 533 | }); | ||
| 534 | + | ||||
| 535 | + | ||||
| 536 | + | test('live refresh preserves the open button panel even when the hash points elsewhere', async () => { | |||
| 537 | + | const { readFileSync } = await import('node:fs'); | |||
| 538 | + | const src = readFileSync(new URL('../static/js/mr.js', import.meta.url), 'utf8'); | |||
| 539 | + | const start = src.indexOf(' async function refreshPage(page)'); | |||
| 540 | + | const end = src.indexOf(' function refreshNotice', start); | |||
| 541 | + | const { el, installDom } = await import('./dom.mjs'); | |||
| 542 | + | const saved = globalThis.document; | |||
| 543 | + | const h = footerHarness(); | |||
| 544 | + | try { | |||
| 545 | + | window.ermiteMR.panels(); | |||
| 546 | + | h.tabs[1].events.click({ preventDefault() {} }); | |||
| 547 | + | location.hash = '#f99'; | |||
| 548 | + | const doc = installDom(); | |||
| 549 | + | Object.defineProperty(doc, 'activeElement', { get: () => null }); | |||
| 550 | + | const diffs = el('div'); | |||
| 551 | + | diffs.dataset.diff = 'unified'; | |||
| 552 | + | const fresh = el('footer', {}, el('section', { attrs: { 'data-mr-panel': '' } }), el('section', { attrs: { 'data-mr-panel': '' } })); | |||
| 553 | + | const page = { body: { dataset: {} } }; | |||
| 554 | + | const $ = (s, root) => s === '#diffs' ? diffs : s === '.mr-footer' ? (root === page ? fresh : h.footer) : el('div'); | |||
| 555 | + | const $$ = (s, root) => s === '[data-mr-tabs] button' ? h.tabs : s === '[data-mr-panel]' ? fresh.children : []; | |||
| 556 | + | let selected; | |||
| 557 | + | const lazy = { reset() {}, watch() {} }; | |||
| 558 | + | const refresh = new Function('$', '$$', 'scrollAnchor', 'hasDraft', 'replaceRegion', 'panels', 'watchBar', 'foldFiles', 'touchComments', 'restoreAnchor', 'window', 'document', | |||
| 559 | + | 'let revealGen = 0; ' + src.slice(start, end) + '; return refreshPage;')( | |||
| 560 | + | $, $$, () => ({}), () => false, async () => {}, (i) => { selected = i; }, () => {}, () => {}, () => {}, () => {}, { ermiteLazy: lazy }, doc); | |||
| 561 | + | await refresh(page); | |||
| 562 | + | assert.equal(selected, 1); | |||
| 563 | + | assert.deepEqual(fresh.children.map((p) => p.hidden), [true, false]); | |||
| 564 | + | } finally { h.restore(); globalThis.document = saved; } | |||
| 565 | + | }); | |||
M internal/adapters/web/overlays.templ +2 -2
| @@ -127,9 +127,9 @@ templ OverlayCmd(items []CmdItem) { | |||
| 127 | 127 | </div> | |
| 128 | 128 | <ul id="cmd-list" class="cmd-list" role="listbox" aria-label="Targets"> | |
| 129 | 129 | for i, c := range items { | |
| 130 | - | <li id={ "cmd-o" + itoa(i) } role="option" aria-selected={ strconv.FormatBool(i == 0) } data-k={ strings.ToLower(c.Kind + " " + c.Label) } data-cursor?={ i == 0 }><a role="presentation" href={ templ.SafeURL(c.Href) } tabindex="-1"><span class="lbl">{ c.Label }</span><span class="k">{ c.Kind }</span></a></li> | |
| 130 | + | <li id={ "cmd-o" + itoa(i) } role="option" aria-selected={ strconv.FormatBool(i == 0) } data-k={ strings.ToLower(c.Kind + " " + c.Label) } data-cursor?={ i == 0 }><a role="presentation" data-href={ c.Href }><span class="lbl">{ c.Label }</span><span class="k">{ c.Kind }</span></a></li> | |
| 131 | 131 | } | |
| 132 | - | <li id={ "cmd-o" + itoa(len(items)) } role="option" aria-selected={ strconv.FormatBool(len(items) == 0) } data-cursor?={ len(items) == 0 } data-k="action turn single-key shortcuts on off keyboard"><a role="presentation" href="#" data-fire="keys" tabindex="-1"><span class="lbl">turn single-key shortcuts off</span><span class="k">action</span></a></li> | |
| 132 | + | <li id={ "cmd-o" + itoa(len(items)) } role="option" aria-selected={ strconv.FormatBool(len(items) == 0) } data-cursor?={ len(items) == 0 } data-k="action turn single-key shortcuts on off keyboard"><a role="presentation" data-fire="keys"><span class="lbl">turn single-key shortcuts off</span><span class="k">action</span></a></li> | |
| 133 | 133 | </ul> | |
| 134 | 134 | <p class="panel-foot"><span><kbd>↑</kbd><kbd>↓</kbd> move</span><span><kbd>enter</kbd> open</span><span><kbd>esc</kbd> close</span></p> | |
| 135 | 135 | </dialog> | |
| @@ -127,9 +127,9 @@ templ OverlayCmd(items []CmdItem) { | |||||
| 127 | </div> | 127 | </div> | ||
| 128 | <ul id="cmd-list" class="cmd-list" role="listbox" aria-label="Targets"> | 128 | <ul id="cmd-list" class="cmd-list" role="listbox" aria-label="Targets"> | ||
| 129 | for i, c := range items { | 129 | for i, c := range items { | ||
| 130 | - | <li id={ "cmd-o" + itoa(i) } role="option" aria-selected={ strconv.FormatBool(i == 0) } data-k={ strings.ToLower(c.Kind + " " + c.Label) } data-cursor?={ i == 0 }><a role="presentation" href={ templ.SafeURL(c.Href) } tabindex="-1"><span class="lbl">{ c.Label }</span><span class="k">{ c.Kind }</span></a></li> | 130 | + | <li id={ "cmd-o" + itoa(i) } role="option" aria-selected={ strconv.FormatBool(i == 0) } data-k={ strings.ToLower(c.Kind + " " + c.Label) } data-cursor?={ i == 0 }><a role="presentation" data-href={ c.Href }><span class="lbl">{ c.Label }</span><span class="k">{ c.Kind }</span></a></li> |
| 131 | } | 131 | } | ||
| 132 | - | <li id={ "cmd-o" + itoa(len(items)) } role="option" aria-selected={ strconv.FormatBool(len(items) == 0) } data-cursor?={ len(items) == 0 } data-k="action turn single-key shortcuts on off keyboard"><a role="presentation" href="#" data-fire="keys" tabindex="-1"><span class="lbl">turn single-key shortcuts off</span><span class="k">action</span></a></li> | 132 | + | <li id={ "cmd-o" + itoa(len(items)) } role="option" aria-selected={ strconv.FormatBool(len(items) == 0) } data-cursor?={ len(items) == 0 } data-k="action turn single-key shortcuts on off keyboard"><a role="presentation" data-fire="keys"><span class="lbl">turn single-key shortcuts off</span><span class="k">action</span></a></li> |
| 133 | </ul> | 133 | </ul> | ||
| 134 | <p class="panel-foot"><span><kbd>↑</kbd><kbd>↓</kbd> move</span><span><kbd>enter</kbd> open</span><span><kbd>esc</kbd> close</span></p> | 134 | <p class="panel-foot"><span><kbd>↑</kbd><kbd>↓</kbd> move</span><span><kbd>enter</kbd> open</span><span><kbd>esc</kbd> close</span></p> | ||
| 135 | </dialog> | 135 | </dialog> | ||
M internal/adapters/web/overlays_templ.go +9 -9 generated file: collapsed
M internal/adapters/web/static/js/ermite.js +10 -1
| @@ -289,7 +289,6 @@ | |||
| 289 | 289 | for (const li of all) { | |
| 290 | 290 | li.id ||= 'cmd-h' + seq++; | |
| 291 | 291 | li.setAttribute('role', 'option'); | |
| 292 | - | li.querySelector('a')?.setAttribute('role', 'presentation'); | |
| 293 | 292 | li.setAttribute('aria-selected', li === cur ? 'true' : 'false'); | |
| 294 | 293 | } | |
| 295 | 294 | input.setAttribute('aria-expanded', shown.length ? 'true' : 'false'); | |
| @@ -678,6 +677,16 @@ | |||
| 678 | 677 | const menu = el.closest('details.menu'); | |
| 679 | 678 | if (menu) closeMenu(menu); | |
| 680 | 679 | }); | |
| 680 | + | // Listbox options own the interaction; their anchors are presentation only. | |
| 681 | + | // Keyboard activation also clicks this wrapper (palette, finder and j/k). | |
| 682 | + | addEventListener('click', (e) => { | |
| 683 | + | const target = e.target.closest?.('a[data-href]'); | |
| 684 | + | const list = target?.closest?.('[role="listbox"]'); | |
| 685 | + | if (!list || !['cmd-list', 'finder-list'].includes(list.id) || e.button) return; | |
| 686 | + | e.preventDefault(); | |
| 687 | + | location.assign(target.dataset.href); | |
| 688 | + | }); | |
| 689 | + | ||
| 681 | 690 | // A click outside an open menu closes it. | |
| 682 | 691 | addEventListener('click', (e) => { | |
| 683 | 692 | for (const d of $$('details.menu[open]')) if (!d.contains(e.target)) d.open = false; | |
| @@ -289,7 +289,6 @@ | |||||
| 289 | for (const li of all) { | 289 | for (const li of all) { | ||
| 290 | li.id ||= 'cmd-h' + seq++; | 290 | li.id ||= 'cmd-h' + seq++; | ||
| 291 | li.setAttribute('role', 'option'); | 291 | li.setAttribute('role', 'option'); | ||
| 292 | - | li.querySelector('a')?.setAttribute('role', 'presentation'); | |||
| 293 | li.setAttribute('aria-selected', li === cur ? 'true' : 'false'); | 292 | li.setAttribute('aria-selected', li === cur ? 'true' : 'false'); | ||
| 294 | } | 293 | } | ||
| 295 | input.setAttribute('aria-expanded', shown.length ? 'true' : 'false'); | 294 | input.setAttribute('aria-expanded', shown.length ? 'true' : 'false'); | ||
| @@ -678,6 +677,16 @@ | |||||
| 678 | const menu = el.closest('details.menu'); | 677 | const menu = el.closest('details.menu'); | ||
| 679 | if (menu) closeMenu(menu); | 678 | if (menu) closeMenu(menu); | ||
| 680 | }); | 679 | }); | ||
| 680 | + | // Listbox options own the interaction; their anchors are presentation only. | |||
| 681 | + | // Keyboard activation also clicks this wrapper (palette, finder and j/k). | |||
| 682 | + | addEventListener('click', (e) => { | |||
| 683 | + | const target = e.target.closest?.('a[data-href]'); | |||
| 684 | + | const list = target?.closest?.('[role="listbox"]'); | |||
| 685 | + | if (!list || !['cmd-list', 'finder-list'].includes(list.id) || e.button) return; | |||
| 686 | + | e.preventDefault(); | |||
| 687 | + | location.assign(target.dataset.href); | |||
| 688 | + | }); | |||
| 689 | + | ||||
| 681 | // A click outside an open menu closes it. | 690 | // A click outside an open menu closes it. | ||
| 682 | addEventListener('click', (e) => { | 691 | addEventListener('click', (e) => { | ||
| 683 | for (const d of $$('details.menu[open]')) if (!d.contains(e.target)) d.open = false; | 692 | for (const d of $$('details.menu[open]')) if (!d.contains(e.target)) d.open = false; | ||
M internal/adapters/web/static/js/files.js +4 -3
| @@ -635,12 +635,12 @@ window.ermiteFinder = (() => { | |||
| 635 | 635 | return lbl; | |
| 636 | 636 | } | |
| 637 | 637 | ||
| 638 | - | // hitLink is the link of path i of the result: its label, out of the tab order. | |
| 638 | + | // hitLink is the presentation wrapper of path i; the option owns activation. | |
| 639 | 639 | function hitLink(res, i) { | |
| 640 | 640 | const path = res.idx.paths[i]; | |
| 641 | 641 | const a = document.createElement('a'); | |
| 642 | - | a.href = blobHref(path); | |
| 643 | - | a.tabIndex = -1; | |
| 642 | + | a.dataset.href = blobHref(path); | |
| 643 | + | a.setAttribute('role', 'presentation'); | |
| 644 | 644 | a.append(label(path, positions(res.idx, i, res.q))); | |
| 645 | 645 | return a; | |
| 646 | 646 | } | |
| @@ -684,6 +684,7 @@ window.ermiteFinder = (() => { | |||
| 684 | 684 | ||
| 685 | 685 | // showTree: no query, the directory again, with j/k and Enter on its rows. | |
| 686 | 686 | function showTree(el) { | |
| 687 | + | status(''); | |
| 687 | 688 | rendered = null; | |
| 688 | 689 | pendingEnter = null; | |
| 689 | 690 | $('finder').hidden = true; | |
| @@ -635,12 +635,12 @@ window.ermiteFinder = (() => { | |||||
| 635 | return lbl; | 635 | return lbl; | ||
| 636 | } | 636 | } | ||
| 637 | 637 | ||||
| 638 | - | // hitLink is the link of path i of the result: its label, out of the tab order. | 638 | + | // hitLink is the presentation wrapper of path i; the option owns activation. |
| 639 | function hitLink(res, i) { | 639 | function hitLink(res, i) { | ||
| 640 | const path = res.idx.paths[i]; | 640 | const path = res.idx.paths[i]; | ||
| 641 | const a = document.createElement('a'); | 641 | const a = document.createElement('a'); | ||
| 642 | - | a.href = blobHref(path); | 642 | + | a.dataset.href = blobHref(path); |
| 643 | - | a.tabIndex = -1; | 643 | + | a.setAttribute('role', 'presentation'); |
| 644 | a.append(label(path, positions(res.idx, i, res.q))); | 644 | a.append(label(path, positions(res.idx, i, res.q))); | ||
| 645 | return a; | 645 | return a; | ||
| 646 | } | 646 | } | ||
| @@ -684,6 +684,7 @@ window.ermiteFinder = (() => { | |||||
| 684 | 684 | ||||
| 685 | // showTree: no query, the directory again, with j/k and Enter on its rows. | 685 | // showTree: no query, the directory again, with j/k and Enter on its rows. | ||
| 686 | function showTree(el) { | 686 | function showTree(el) { | ||
| 687 | + | status(''); | |||
| 687 | rendered = null; | 688 | rendered = null; | ||
| 688 | pendingEnter = null; | 689 | pendingEnter = null; | ||
| 689 | $('finder').hidden = true; | 690 | $('finder').hidden = true; | ||
M internal/adapters/web/static/js/mr.js +1 -1
| @@ -522,7 +522,7 @@ window.ermiteMR = (() => { | |||
| 522 | 522 | const files = new Map($$('#diffs details.dfile').map((f) => [f.dataset.file, f.open])); | |
| 523 | 523 | const folded = $('.r-files')?.hasAttribute('data-folded'); | |
| 524 | 524 | const railY = $('.rail')?.scrollTop, filesY = $('.r-files .files')?.scrollTop; | |
| 525 | - | const openPanel = $$('[data-mr-tabs] a').findIndex((t) => t.getAttribute('aria-expanded') === 'true'); | |
| 525 | + | const openPanel = $$('[data-mr-tabs] button').findIndex((t) => t.getAttribute('aria-expanded') === 'true'); | |
| 526 | 526 | const active = document.activeElement; | |
| 527 | 527 | const focus = active && { file: active.closest?.('.files a')?.getAttribute('title'), region: regions.find((sel) => $(sel)?.contains(active)), menu: active.closest?.('details.menu')?.id, id: active.id, tag: active.tagName, name: active.getAttribute('name'), href: active.getAttribute('href') }; | |
| 528 | 528 | for (const f of $$('#diffs details.dfile', page)) if (files.has(f.dataset.file)) f.open = files.get(f.dataset.file); | |
| @@ -522,7 +522,7 @@ window.ermiteMR = (() => { | |||||
| 522 | const files = new Map($$('#diffs details.dfile').map((f) => [f.dataset.file, f.open])); | 522 | const files = new Map($$('#diffs details.dfile').map((f) => [f.dataset.file, f.open])); | ||
| 523 | const folded = $('.r-files')?.hasAttribute('data-folded'); | 523 | const folded = $('.r-files')?.hasAttribute('data-folded'); | ||
| 524 | const railY = $('.rail')?.scrollTop, filesY = $('.r-files .files')?.scrollTop; | 524 | const railY = $('.rail')?.scrollTop, filesY = $('.r-files .files')?.scrollTop; | ||
| 525 | - | const openPanel = $$('[data-mr-tabs] a').findIndex((t) => t.getAttribute('aria-expanded') === 'true'); | 525 | + | const openPanel = $$('[data-mr-tabs] button').findIndex((t) => t.getAttribute('aria-expanded') === 'true'); |
| 526 | const active = document.activeElement; | 526 | const active = document.activeElement; | ||
| 527 | const focus = active && { file: active.closest?.('.files a')?.getAttribute('title'), region: regions.find((sel) => $(sel)?.contains(active)), menu: active.closest?.('details.menu')?.id, id: active.id, tag: active.tagName, name: active.getAttribute('name'), href: active.getAttribute('href') }; | 527 | const focus = active && { file: active.closest?.('.files a')?.getAttribute('title'), region: regions.find((sel) => $(sel)?.contains(active)), menu: active.closest?.('details.menu')?.id, id: active.id, tag: active.tagName, name: active.getAttribute('name'), href: active.getAttribute('href') }; | ||
| 528 | for (const f of $$('#diffs details.dfile', page)) if (files.has(f.dataset.file)) f.open = files.get(f.dataset.file); | 528 | for (const f of $$('#diffs details.dfile', page)) if (files.has(f.dataset.file)) f.open = files.get(f.dataset.file); | ||