docs: add source reference and author attribution to ConfirmationDialog and useConfirmationStore
This commit is contained in:
parent
bb2093d14f
commit
398c56b38b
@ -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";
|
"use client";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -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";
|
import { create } from "zustand";
|
||||||
|
|
||||||
interface ConfirmationState {
|
interface ConfirmationState {
|
||||||
@ -42,10 +45,14 @@ const useConfirmationStore = create<ConfirmationState & ConfirmationActions>(
|
|||||||
onAction: data.onAction,
|
onAction: data.onAction,
|
||||||
})),
|
})),
|
||||||
closeConfirmation: () => {
|
closeConfirmation: () => {
|
||||||
|
// Close the confirmation dialog by setting the 'open' state to false.
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
...state,
|
...state,
|
||||||
open: false,
|
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(() => {
|
setTimeout(() => {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
...state,
|
...state,
|
||||||
|
Loading…
Reference in New Issue
Block a user