Skip to content

Commit 6717904

Browse files
committed
Fix scroll into view for headers on a page when linking to a specific header. fix #288
1 parent b53557d commit 6717904

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/openapi-explorer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,11 @@ export default class OpenApiExplorer extends LitElement {
567567

568568
// explorerLocation will get validated in the focused-endpoint-template
569569
this.explorerLocation = elementId;
570-
const tag = this.resolvedSpec.tags.find(t => t.paths.some(p => p.elementId === elementId));
571-
if (tag) {
572-
tag.expanded = true;
570+
const tagFoundByPath = this.resolvedSpec.tags.find(t => t.paths.some(p => p.elementId === elementId));
571+
if (tagFoundByPath) {
572+
tagFoundByPath.expanded = true;
573573
}
574+
574575
// Convert to Async and to the background, so that we can be sure that the operation has been expanded and put into view before trying to directly scroll to it (or it won't be found in the next line and even if it is, it might not be able to be scrolled into view)
575576
await sleep(0);
576577

@@ -619,7 +620,7 @@ export default class OpenApiExplorer extends LitElement {
619620
// Update Location Hash
620621
replaceState(elementId);
621622
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
622-
} else if (!elementId.match('cmp--') && !elementId.match('tag--')) {
623+
} else if (!elementId.match('cmp--') && !elementId.match('tag--') && !elementId.match(/--h[12]$/)) {
623624
this.shadowRoot.getElementById('operations-root').scrollIntoView({ behavior: 'auto', block: 'start' });
624625

625626
// Update Location Hash

0 commit comments

Comments
 (0)