From acf45530cad0f1981fab7143c233605322073ddd Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 15 Oct 2025 18:15:55 +0200 Subject: [PATCH] refactor: replace delete dialog with inline confirmation Replace popup modal with inline confirmation UI: - When delete is clicked, show red trash icon with 'Confirm?' text - Clicking red trash icon again confirms deletion - Confirmation appears to left of three-dot menu - Click outside or reopen menu cancels confirmation - Remove ConfirmDialog component dependency --- src/components/HighlightItem.tsx | 45 +++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/components/HighlightItem.tsx b/src/components/HighlightItem.tsx index 9d60982c..0e6f880d 100644 --- a/src/components/HighlightItem.tsx +++ b/src/components/HighlightItem.tsx @@ -13,7 +13,6 @@ import { areAllRelaysLocal } from '../utils/helpers' import { nip19 } from 'nostr-tools' import { formatDateCompact } from '../utils/bookmarkUtils' import { createDeletionRequest } from '../services/deletionService' -import ConfirmDialog from './ConfirmDialog' import { getNostrUrl } from '../config/nostrGateways' import CompactButton from './CompactButton' import { HighlightCitation } from './HighlightCitation' @@ -257,21 +256,22 @@ export const HighlightItem: React.FC = ({ } }, [isSelected]) - // Close menu when clicking outside + // Close menu and reset delete confirm when clicking outside useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (menuRef.current && !menuRef.current.contains(event.target as Node)) { setShowMenu(false) + setShowDeleteConfirm(false) } } - if (showMenu) { + if (showMenu || showDeleteConfirm) { document.addEventListener('mousedown', handleClickOutside) return () => { document.removeEventListener('mousedown', handleClickOutside) } } - }, [showMenu]) + }, [showMenu, showDeleteConfirm]) const handleItemClick = () => { if (onHighlightClick) { @@ -440,6 +440,10 @@ export const HighlightItem: React.FC = ({ const handleMenuToggle = (e: React.MouseEvent) => { e.stopPropagation() + // Reset delete confirm state when opening/closing menu + if (!showMenu) { + setShowDeleteConfirm(false) + } setShowMenu(!showMenu) } @@ -461,6 +465,11 @@ export const HighlightItem: React.FC = ({ setShowDeleteConfirm(true) } + const handleConfirmDeleteClick = (e: React.MouseEvent) => { + e.stopPropagation() + handleConfirmDelete() + } + return ( <>
= ({
+ {showDeleteConfirm && canDelete && ( +
+ Confirm? + +
+ )} + = ({
- - ) }