Browse Source

Fixed click bug from reply form

imwald
Silberengel 4 months ago
parent
commit
2b5aca4b00
  1. 4
      src/components/NoteStats/index.tsx
  2. 22
      src/components/NotificationList/NotificationItem/Notification.tsx

4
src/components/NoteStats/index.tsx

@ -70,7 +70,7 @@ export default function NoteStats({
if (isSmallScreen) { if (isSmallScreen) {
return ( return (
<div className={cn('select-none', className)}> <div className={cn('select-none', className)} data-note-stats onClick={(e) => e.stopPropagation()}>
{displayTopZapsAndLikes && ( {displayTopZapsAndLikes && (
<> <>
<TopZaps event={event} /> <TopZaps event={event} />
@ -96,7 +96,7 @@ export default function NoteStats({
} }
return ( return (
<div className={cn('select-none', className)}> <div className={cn('select-none', className)} data-note-stats onClick={(e) => e.stopPropagation()}>
{displayTopZapsAndLikes && ( {displayTopZapsAndLikes && (
<> <>
<TopZaps event={event} /> <TopZaps event={event} />

22
src/components/NotificationList/NotificationItem/Notification.tsx

@ -47,7 +47,27 @@ export default function Notification({
[isNew, isNotificationRead, notificationId] [isNew, isNotificationRead, notificationId]
) )
const handleClick = () => { const handleClick = (e: React.MouseEvent) => {
// Don't navigate if clicking on interactive elements (buttons, links, etc.)
const target = e.target as HTMLElement
if (target.closest('button') || target.closest('[role="button"]') || target.closest('a')) {
return
}
// Don't navigate if clicking within NoteStats (which contains the ReplyButton)
// NoteStats is rendered inside the notification, so we need to check for it
if (target.closest('[data-note-stats]')) {
return
}
// Don't navigate if a modal/dialog/sheet is currently open
// Check for Radix UI dialog/sheet elements in the DOM
// Radix UI uses data-radix-dialog-content for the dialog content
const hasOpenModal = document.querySelector('[data-radix-dialog-content][data-state="open"]')
if (hasOpenModal) {
return
}
markNotificationAsRead(notificationId) markNotificationAsRead(notificationId)
if (targetEvent) { if (targetEvent) {
navigateToNote(toNote(targetEvent.id)) navigateToNote(toNote(targetEvent.id))

Loading…
Cancel
Save