Skip to content

Commit 01dfeb4

Browse files
committed
correct focus after interactions
1 parent 241dc32 commit 01dfeb4

2 files changed

Lines changed: 7 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);

src/utils/common-utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function copyToClipboard(copyData, eventTarget) {
4747
setTimeout(() => {
4848
btnEl.innerText = getI18nText('operations.copy');
4949
}, 5000);
50+
btnEl.focus();
5051
}
5152
} catch (err) {
5253
console.error('Unable to copy', err); // eslint-disable-line no-console

0 commit comments

Comments
 (0)