From 398c56b38b4af2e557b9b422435a74b98efc0ab0 Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Mon, 9 Dec 2024 13:39:27 +0800 Subject: [PATCH] docs: add source reference and author attribution to ConfirmationDialog and useConfirmationStore --- src/dialogs/ConfirmationDialog.tsx | 3 +++ src/store/confirmationStore.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/dialogs/ConfirmationDialog.tsx b/src/dialogs/ConfirmationDialog.tsx index 816009b..fcd91eb 100644 --- a/src/dialogs/ConfirmationDialog.tsx +++ b/src/dialogs/ConfirmationDialog.tsx @@ -1,3 +1,6 @@ +// This implementation is derived from the solution provided by [baydisng13] in the discussion thread: +// https://github.com/shadcn-ui/ui/discussions/3875 + "use client"; import React from "react"; diff --git a/src/store/confirmationStore.ts b/src/store/confirmationStore.ts index 2a75b47..13e7b85 100644 --- a/src/store/confirmationStore.ts +++ b/src/store/confirmationStore.ts @@ -1,3 +1,6 @@ +// This implementation is derived from the solution provided by [baydisng13] in the discussion thread: +// https://github.com/shadcn-ui/ui/discussions/3875 + import { create } from "zustand"; interface ConfirmationState { @@ -42,10 +45,14 @@ const useConfirmationStore = create( onAction: data.onAction, })), closeConfirmation: () => { + // Close the confirmation dialog by setting the 'open' state to false. set((state) => ({ ...state, open: false, })); + // After a short delay (100ms), reset the dialog's state to its initial values. + // This delay ensures that the dialog is fully closed before resetting, + // preventing any visual flickering or UI inconsistencies. setTimeout(() => { set((state) => ({ ...state,