Skip to content

Commit dc2d84a

Browse files
fix: use Link instead anchor tag
1 parent 057ae57 commit dc2d84a

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

src/optimizer-page/scan-results/BrokenLinkTable.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '../../constants';
2626
import { buildBlockContainerUrl } from '../utils';
2727
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
28+
import { Link } from 'react-router-dom';
2829

2930
const BrokenLinkHref: FC<{ href: string; }> = ({ href }) => {
3031
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
@@ -42,16 +43,12 @@ const BrokenLinkHref: FC<{ href: string; }> = ({ href }) => {
4243
};
4344

4445
const GoToBlock: FC<{ block: { url: string; displayName?: string; }; }> = ({ block }) => {
45-
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
46-
event.preventDefault();
47-
window.open(block.url, '_blank');
48-
};
4946

5047
return (
5148
<div className="go-to-block-link-container">
52-
<a href={block.url} onClick={handleClick} className="broken-link" rel="noreferrer">
49+
<Link to={block.url} className="broken-link" rel="noreferrer" target="_blank">
5350
{block.displayName}
54-
</a>
51+
</Link>
5552
</div>
5653
);
5754
};

src/optimizer-page/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { createCorrectInternalRoute } from '../utils';
21
import { LinkCheckResult } from './types';
32

43
export const buildBlockContainerUrl = (
54
courseId: string,
65
unitId: string,
76
blockId: string,
87
): string => {
9-
const path = `/course/${courseId}/container/${unitId}#${blockId}`;
10-
const internalPath = createCorrectInternalRoute(path);
11-
return internalPath;
8+
return `/course/${courseId}/container/${unitId}#${blockId}`;
129
};
1310

1411
export const countBrokenLinks = (

0 commit comments

Comments
 (0)