From cbf6f3c6b695bc7382f2d8193df32e2073299ae7 Mon Sep 17 00:00:00 2001 From: Paul Bailey Date: Tue, 2 Dec 2025 14:41:42 +0000 Subject: [PATCH] Fix delete button not refreshing UI after deletion - Remove router.push() logic that was preventing refresh - Always call router.refresh() after successful deletion - Reset state before refresh to clear 'Deleting...' text - Item now disappears immediately after deletion --- components/DeleteItemButton.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/DeleteItemButton.tsx b/components/DeleteItemButton.tsx index cb92706..c41acf1 100644 --- a/components/DeleteItemButton.tsx +++ b/components/DeleteItemButton.tsx @@ -26,15 +26,12 @@ export default function DeleteItemButton({ itemId, listId, variant = 'full' }: D await deleteItem(itemId) showToast('Task deleted successfully', 'success') setShowConfirm(false) - if (listId) { - router.push(`/list/${listId}`) - } else { - router.refresh() - } + setIsDeleting(false) + // Always refresh to update the UI + router.refresh() } catch (error) { console.error('Error deleting item:', error) showToast('Failed to delete task', 'error') - } finally { setIsDeleting(false) setShowConfirm(false) }