Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 91563bd

Browse files
fix: fix scroll to top issue
1 parent 12dab35 commit 91563bd

File tree

1 file changed

+7
-7
lines changed
  • src/features/Apiexplorer/Schema/HighlightCode

1 file changed

+7
-7
lines changed

src/features/Apiexplorer/Schema/HighlightCode/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import clsx from 'clsx';
3-
import styles from './HighlightCode.module.scss';
3+
import { useHistory, useLocation } from '@docusaurus/router';
44
import { playground_requests } from '@site/src/utils/playground_requests';
55
import { SchemaDescriptionTypes } from '../RecursiveContent/SchemaDescription';
6-
import { useHistory, useLocation } from '@docusaurus/router';
6+
import styles from './HighlightCode.module.scss';
77

88
export const HighlightCode = ({ description }: SchemaDescriptionTypes) => {
99
const { pathname } = useLocation();
@@ -13,19 +13,19 @@ export const HighlightCode = ({ description }: SchemaDescriptionTypes) => {
1313

1414
const [first, code, ...rest] = description.split('`');
1515

16-
const api_call_object = playground_requests.find((el) => el.name === code);
17-
const link_api_call = (obj) => {
16+
const has_api_call = playground_requests.some((el) => el.name === code);
17+
const link_api_call = (api_call_name) => {
1818
window.scrollTo(0, 0);
19-
history.push(`${pathname}#${obj?.name}`);
19+
history.push(`${pathname}#${api_call_name}`);
2020
};
2121

2222
return (
2323
<React.Fragment>
2424
{first}
2525
{code && (
2626
<span className={clsx(styles.schemaRole, styles.schemaCode)}>
27-
{api_call_object ? (
28-
<button onClick={() => link_api_call(api_call_object)} className={styles.schemaLink}>
27+
{has_api_call ? (
28+
<button onClick={() => link_api_call(code)} className={styles.schemaLink}>
2929
{code}
3030
</button>
3131
) : (

0 commit comments

Comments
 (0)