Skip to content

Commit 9f97996

Browse files
authored
Merge pull request #312 from ahamelers/accessibility/focus
Correct lost/incorrect focus after interactions
2 parents 241dc32 + 34208b4 commit 9f97996

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/openapi-explorer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ export default class OpenApiExplorer extends LitElement {
423423
const gotoEl = this.shadowRoot.getElementById(tmpElementId);
424424
if (gotoEl) {
425425
gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
426+
gotoEl.focus();
426427
replaceState(tmpElementId);
427428
}
428429
}, isExpandingNeeded ? 150 : 0);
@@ -459,6 +460,7 @@ export default class OpenApiExplorer extends LitElement {
459460
const gotoEl = this.shadowRoot.getElementById(anchor.replace('#', ''));
460461
if (gotoEl) {
461462
gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
463+
gotoEl.focus();
462464
}
463465
}
464466
}
@@ -603,19 +605,21 @@ export default class OpenApiExplorer extends LitElement {
603605
component.expanded = true;
604606
}
605607
contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
608+
contentEl.focus();
606609

607610
// Update Location Hash
608611
replaceState(elementId);
609612
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
610613
} else if (elementId.match('cmp--') || elementId.match('tag--') || elementId.match('overview--') || elementId.match('auth--') || elementId.match('servers--')) {
611614
contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
615+
contentEl.focus();
612616

613617
// Update Location Hash
614618
replaceState(elementId);
615619
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
616620
} else {
617621
this.shadowRoot.getElementById('operations-root').scrollIntoView({ behavior: 'auto', block: 'start' });
618-
622+
this.shadowRoot.getElementById('operations-root').focus();
619623
// Update Location Hash
620624
replaceState(elementId);
621625
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
@@ -642,6 +646,7 @@ export default class OpenApiExplorer extends LitElement {
642646
if (waitForComponentToExpand) {
643647
setTimeout(() => newNavEl.scrollIntoView({ behavior: 'auto', block: 'center' }), 600);
644648
}
649+
newNavEl.focus();
645650
}
646651

647652
await sleep(0);

0 commit comments

Comments
 (0)