fix: reset capture viewport after keyboard navigation

This commit is contained in:
timmy 2026-08-17 22:58:22 +00:00
parent 89c25369fc
commit 58299311d0
2 changed files with 7 additions and 3 deletions

View File

@ -53,6 +53,8 @@ function createIssueModalLifecycle({ root, background = [], document, requestClo
active = false; active = false;
backgroundState.forEach(([element, inert]) => { element.inert = inert; }); backgroundState.forEach(([element, inert]) => { element.inert = inert; });
backgroundState = []; backgroundState = [];
const panel = root.querySelector('.create-issue-panel');
if (panel) panel.scrollTop = 0;
if (restore && launcher?.isConnected) launcher.focus(); if (restore && launcher?.isConnected) launcher.focus();
launcher = null; launcher = null;
}, },

View File

@ -30,9 +30,11 @@ function element(id) {{
const launcher = element('mobile-new'); const launcher = element('mobile-new');
const cancel = element('cancel-new-issue'); const cancel = element('cancel-new-issue');
const title = element('create-issue-title'); const title = element('create-issue-title');
const panel = {{...element('create-issue-panel'), scrollTop:420}};
const background = [element('header'), element('main'), element('mobile-task-dock')]; const background = [element('header'), element('main'), element('mobile-task-dock')];
const root = {{ const root = {{
querySelector: selector => selector === '#cancel-new-issue' ? cancel : null, querySelector: selector => selector === '#cancel-new-issue' ? cancel :
(selector === '.create-issue-panel' ? panel : null),
querySelectorAll: () => [cancel, title], querySelectorAll: () => [cancel, title],
addEventListener() {{}}, removeEventListener() {{}}, addEventListener() {{}}, removeEventListener() {{}},
}}; }};
@ -44,14 +46,14 @@ lifecycle.open(launcher);
const opened = {{active:document.activeElement.id, inert:background.map(item => item.inert)}}; const opened = {{active:document.activeElement.id, inert:background.map(item => item.inert)}};
lifecycle.close(); lifecycle.close();
process.stdout.write(JSON.stringify({{ process.stdout.write(JSON.stringify({{
opened, closed:{{active:document.activeElement.id, inert:background.map(item => item.inert)}} opened, closed:{{active:document.activeElement.id, inert:background.map(item => item.inert), scrollTop:panel.scrollTop}}
}})); }}));
""" """
) )
assert result == { assert result == {
"opened": {"active": "cancel-new-issue", "inert": [True, True, True]}, "opened": {"active": "cancel-new-issue", "inert": [True, True, True]},
"closed": {"active": "mobile-new", "inert": [False, False, False]}, "closed": {"active": "mobile-new", "inert": [False, False, False], "scrollTop": 0},
} }