Skip to content

Commit 4998a2b

Browse files
[docs] Fix TOCs open in new tab
Closes #18756
1 parent 8754890 commit 4998a2b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/src/modules/components/AppTableOfContents.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Typography from '@material-ui/core/Typography';
1111
import textToHash from 'docs/src/modules/utils/textToHash';
1212
import DiamondSponsors from 'docs/src/modules/components/DiamondSponsors';
1313
import Link from 'docs/src/modules/components/Link';
14+
import PageContext from 'docs/src/modules/components/PageContext';
1415

1516
const useStyles = makeStyles(theme => ({
1617
root: {
@@ -155,6 +156,7 @@ export default function AppTableOfContents(props) {
155156
itemsClientRef.current = getItemsClient(itemsServer);
156157
}, [itemsServer]);
157158

159+
const { activePage } = React.useContext(PageContext);
158160
const [activeState, setActiveState] = React.useState(null);
159161
const clickedRef = React.useRef(false);
160162
const unsetClickedRef = React.useRef(null);
@@ -233,7 +235,7 @@ export default function AppTableOfContents(props) {
233235
<Link
234236
display="block"
235237
color={activeState === item.hash ? 'textPrimary' : 'textSecondary'}
236-
href={`#${item.hash}`}
238+
href={`${activePage.pathname}#${item.hash}`}
237239
underline="none"
238240
onClick={handleClick(item.hash)}
239241
className={clsx(

0 commit comments

Comments
 (0)