Skip to content

Commit 412f4fe

Browse files
authored
Merge pull request #172 from balena-io-modules/markdown-stopevent
Markdown: Stop propagation for links
2 parents 0d3c851 + 47d4ee5 commit 412f4fe

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

src/components/Markdown/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ const defaultMarkdownComponentOverrides: ReactMarkdownOptions['components'] = {
9494
<MUILinkWithTracking
9595
target="_blank"
9696
rel="noreferrer"
97+
onClick={(e) => {
98+
e.stopPropagation();
99+
}}
97100
{...(props as MUILinkWithTrackingProps)}
98101
/>
99102
),

src/components/RJST/components/Filters/Views.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { color } from '@balena/design-tokens';
1616
import type { DropDownButtonProps } from '../../../DropDownButton';
1717
import { DropDownButton } from '../../../DropDownButton';
18-
import { stopEvent } from '../../utils';
18+
import { stopEvent } from '../../../../utils/eventHandling';
1919
import { Tooltip } from '../../../Tooltip';
2020

2121
interface FiltersView {

src/components/RJST/utils.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ export const diff = <T>(a: T, b: T) => {
2121
return a > b ? 1 : -1;
2222
};
2323

24-
export const stopEvent = (event: React.MouseEvent<HTMLElement>) => {
25-
event.preventDefault();
26-
event.stopPropagation();
27-
};
28-
2924
export const getFromLocalStorage = <T>(key: string): T | undefined => {
3025
try {
3126
const val = localStorage.getItem(key);

src/components/TagManagementDialog/AddTagForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { Callout } from '../Callout';
99
import { designTokens } from '../..';
1010
import type { TFunction } from '../../hooks/useTranslations';
1111
import { useTranslation } from '../../hooks/useTranslations';
12-
import { stopKeyDownEvent, withPreventDefault } from './utils';
12+
import {
13+
stopKeyDownEvent,
14+
withPreventDefault,
15+
} from '../../utils/eventHandling';
1316
import {
1417
type SimpleConfirmationDialogProps,
1518
SimpleConfirmationDialog,

src/components/TagManagementDialog/TagLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { TypographyProps } from '@mui/material';
77
import { ClickAwayListener, styled, Tooltip, Typography } from '@mui/material';
88
import { useTranslation } from '../../hooks/useTranslations';
99
import { copyToClipboard } from '../Copy';
10-
import { stopEvent } from './utils';
10+
import { stopEvent } from '../../utils/eventHandling';
1111

1212
const Label = styled(Typography)(({ theme }) => ({
1313
display: 'inline-flex',

src/components/TagManagementDialog/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ import {
3535
import { useTranslation } from '../../hooks/useTranslations';
3636
import { CollectionSummary } from '../CollectionSummary';
3737
import { DialogWithCloseButton } from '../DialogWithCloseButton';
38-
import { stopKeyDownEvent, withPreventDefault } from './utils';
38+
import {
39+
stopKeyDownEvent,
40+
withPreventDefault,
41+
} from '../../utils/eventHandling';
3942

4043
const NBSP = '\u00a0';
4144

File renamed without changes.

0 commit comments

Comments
 (0)