Skip to content

Commit

Permalink
[docs]: fixed scroll to anchor block
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyManetov committed Oct 16, 2023
1 parent 458dcd6 commit 4765297
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/src/common/docs/DocExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ export class DocExample extends React.Component<DocExampleProps, DocExampleState
});
}

if (this.titleRef?.current && window.location?.hash?.includes(this.titleRef.current.id)) {
this.titleRef.current.scrollIntoView(true);
}

svc.api
.getCode({ path })
.then((r) => {
this.setState({ code: r.highlighted, raw: r.raw });

this.scrollToView();
});
}

private scrollToView() {
if (this.titleRef?.current && window.location?.hash?.includes(this.titleRef.current.id)) {
this.titleRef.current.scrollIntoView(true);
}
}

state: DocExampleState = {
showCode: false,
stylesheets: {},
Expand Down

0 comments on commit 4765297

Please sign in to comment.