about summary refs log tree commit diff
path: root/src/components/Dialog/context.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-02-20 18:20:59 -0600
committerGitHub <noreply@github.com>2024-02-20 18:20:59 -0600
commitf88b16525498584f81ea7f594a63623fc5dc7ce9 (patch)
tree0f87d5dc87778da6b4451be536437a432adfbf91 /src/components/Dialog/context.ts
parent6413b8ba8cbf73678d0f1687153b16f3a44f08b0 (diff)
downloadvoidsky-f88b16525498584f81ea7f594a63623fc5dc7ce9.tar.zst
Add optional close callback to Dialog (#2947)
* Add optional close callback

* No emitter
Diffstat (limited to 'src/components/Dialog/context.ts')
-rw-r--r--src/components/Dialog/context.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/components/Dialog/context.ts b/src/components/Dialog/context.ts
index b28b9f5a2..f0c7c983a 100644
--- a/src/components/Dialog/context.ts
+++ b/src/components/Dialog/context.ts
@@ -1,7 +1,11 @@
 import React from 'react'
 
 import {useDialogStateContext} from '#/state/dialogs'
-import {DialogContextProps, DialogControlProps} from '#/components/Dialog/types'
+import {
+  DialogContextProps,
+  DialogControlProps,
+  DialogOuterProps,
+} from '#/components/Dialog/types'
 
 export const Context = React.createContext<DialogContextProps>({
   close: () => {},
@@ -11,7 +15,7 @@ export function useDialogContext() {
   return React.useContext(Context)
 }
 
-export function useDialogControl() {
+export function useDialogControl(): DialogOuterProps['control'] {
   const id = React.useId()
   const control = React.useRef<DialogControlProps>({
     open: () => {},
@@ -30,6 +34,6 @@ export function useDialogControl() {
   return {
     ref: control,
     open: () => control.current.open(),
-    close: () => control.current.close(),
+    close: cb => control.current.close(cb),
   }
 }