refactor: update notification item components to use button elements for better accessibility

This commit is contained in:
Moyasee
2025-12-26 23:37:35 +02:00
parent a74b557d13
commit 0b4d31e482
2 changed files with 7 additions and 19 deletions

View File

@@ -25,7 +25,7 @@ export function LocalNotificationItem({
notification,
onDismiss,
onMarkAsRead,
}: LocalNotificationItemProps) {
}: Readonly<LocalNotificationItemProps>) {
const { t } = useTranslation("notifications_page");
const { formatDistance } = useDate();
const navigate = useNavigate();
@@ -64,18 +64,12 @@ export function LocalNotificationItem({
};
return (
<div
<button
type="button"
className={cn("notification-item", {
"notification-item--unread": !notification.isRead,
})}
onClick={handleClick}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
handleClick();
}
}}
role="button"
tabIndex={0}
>
<div className="notification-item__picture">
{notification.pictureUrl ? (
@@ -104,6 +98,6 @@ export function LocalNotificationItem({
>
<XIcon size={16} />
</button>
</div>
</button>
);
}

View File

@@ -172,20 +172,14 @@ export function NotificationItem({
};
return (
<div
<button
type="button"
className={cn("notification-item", {
"notification-item--unread":
!notification.isRead ||
notification.type === "FRIEND_REQUEST_RECEIVED",
})}
onClick={handleClick}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
handleClick();
}
}}
role="button"
tabIndex={0}
>
<div
className={cn("notification-item__picture", {
@@ -229,6 +223,6 @@ export function NotificationItem({
<XIcon size={16} />
</button>
)}
</div>
</button>
);
}