From 2440975bd224e4c39b633b21c461cb8b8d3c1f9b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 28 Feb 2024 20:06:26 -0600 Subject: Integrate new dialogs into old back handling (#3023) --- src/components/Dialog/context.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/components/Dialog/context.ts') diff --git a/src/components/Dialog/context.ts b/src/components/Dialog/context.ts index f0c7c983a..eb717d8e2 100644 --- a/src/components/Dialog/context.ts +++ b/src/components/Dialog/context.ts @@ -3,7 +3,7 @@ import React from 'react' import {useDialogStateContext} from '#/state/dialogs' import { DialogContextProps, - DialogControlProps, + DialogControlRefProps, DialogOuterProps, } from '#/components/Dialog/types' @@ -17,7 +17,7 @@ export function useDialogContext() { export function useDialogControl(): DialogOuterProps['control'] { const id = React.useId() - const control = React.useRef({ + const control = React.useRef({ open: () => {}, close: () => {}, }) @@ -32,8 +32,13 @@ export function useDialogControl(): DialogOuterProps['control'] { }, [id, activeDialogs]) return { + id, ref: control, - open: () => control.current.open(), - close: cb => control.current.close(cb), + open: () => { + control.current.open() + }, + close: cb => { + control.current.close(cb) + }, } } -- cgit 1.4.1