Skip to content

Commit 5faff22

Browse files
authored
refactor: fix event prop on click and subtle ui tweaks (#1291)
1 parent c24b5cc commit 5faff22

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

src/components/AccountNotifications.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ChevronLeftIcon,
44
ChevronUpIcon,
55
} from '@primer/octicons-react';
6-
import { type FC, useContext, useState } from 'react';
6+
import { type FC, type MouseEvent, useContext, useState } from 'react';
77
import { AppContext } from '../context/App';
88
import { type Account, Size } from '../types';
99
import type { Notification } from '../typesGitHub';
@@ -72,7 +72,11 @@ export const AccountNotifications: FC<IAccountNotifications> = (
7272
<button
7373
type="button"
7474
title="Open Profile"
75-
onClick={() => openAccountProfile(account)}
75+
onClick={(event: MouseEvent<HTMLElement>) => {
76+
// Don't trigger onClick of parent element.
77+
event.stopPropagation();
78+
openAccountProfile(account);
79+
}}
7680
className="opacity-80"
7781
>
7882
@{account.user.login}

src/components/NotificationRow.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,13 @@ export const NotificationRow: FC<INotificationRow> = ({
149149
/>
150150
</span>
151151
<span
152+
title={repoSlug}
152153
className="cursor-pointer truncate opacity-90"
153-
onClick={() => openRepository(notification.repository)}
154+
onClick={(event: MouseEvent<HTMLElement>) => {
155+
// Don't trigger onClick of parent element.
156+
event.stopPropagation();
157+
openRepository(notification.repository);
158+
}}
154159
>
155160
{repoSlug}
156161
</span>

src/components/RepositoryNotifications.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import {
55
MarkGithubIcon,
66
ReadIcon,
77
} from '@primer/octicons-react';
8-
import { type FC, useCallback, useContext, useState } from 'react';
8+
import {
9+
type FC,
10+
type MouseEvent,
11+
useCallback,
12+
useContext,
13+
useState,
14+
} from 'react';
915
import { AppContext } from '../context/App';
1016
import { Size } from '../types';
1117
import type { Notification } from '../typesGitHub';
@@ -65,7 +71,11 @@ export const RepositoryNotifications: FC<IRepositoryNotifications> = ({
6571
/>
6672
<span
6773
className="cursor-pointer truncate opacity-90"
68-
onClick={() => openRepository(repoNotifications[0].repository)}
74+
onClick={(event: MouseEvent<HTMLElement>) => {
75+
// Don't trigger onClick of parent element.
76+
event.stopPropagation();
77+
openRepository(repoNotifications[0].repository);
78+
}}
6979
>
7080
{repoName}
7181
</span>

src/components/__snapshots__/AccountNotifications.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/__snapshots__/NotificationRow.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)