Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use div instead of Nextlink to avoid event propagation #1737

Merged
merged 1 commit into from
Feb 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions website/src/components/Messages/MessageTableEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
import NextLink from "next/link";
import { useRouter } from "next/router";
import { useTranslation } from "next-i18next";
import { lazy, Suspense, useEffect, useMemo, useState } from "react";
import { lazy, Suspense, useCallback, useEffect, useMemo, useState } from "react";
import { LabelMessagePopup } from "src/components/Messages/LabelPopup";
import { MessageEmojiButton } from "src/components/Messages/MessageEmojiButton";
import { ReportPopup } from "src/components/Messages/ReportPopup";
Expand Down Expand Up @@ -106,12 +106,15 @@ export function MessageTableEntry({ message, enabled, highlight, showAuthorBadge
const isAdminOrMod = useHasAnyRole(["admin", "moderator"]);
const { t } = useTranslation(["message"]);

const router = useRouter();
const handleOnClick = useCallback(() => {
enabled && router.push(ROUTES.MESSAGE_DETAIL(message.id));
}, [enabled, message.id, router]);

return (
<HStack w={["full", "full", "full", "fit-content"]} gap={0.5} alignItems="start" maxW="full" position="relative">
{!inlineAvatar && avatar}
<Box
as={enabled ? NextLink : undefined}
href={enabled ? ROUTES.MESSAGE_DETAIL(message.id) : undefined}
width={["full", "full", "full", "fit-content"]}
maxWidth={["full", "full", "full", "2xl"]}
p={[3, 4]}
Expand All @@ -121,6 +124,7 @@ export function MessageTableEntry({ message, enabled, highlight, showAuthorBadge
outlineColor={highlightColor}
cursor={enabled ? "pointer" : undefined}
overflowX="auto"
onClick={handleOnClick}
>
{inlineAvatar && avatar}
<Suspense fallback={message.text}>
Expand Down