From 6b2ccd8d9ff0fc9e9901f7cb4f995a303eac1103 Mon Sep 17 00:00:00 2001 From: sirineJ <112706079+sirineJ@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:29:09 +0100 Subject: [PATCH] adjust children type for compatibility --- packages/circuit-ui/components/Dialog/Dialog.tsx | 6 ++++-- packages/circuit-ui/components/Dialog/ModalContext.tsx | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/circuit-ui/components/Dialog/Dialog.tsx b/packages/circuit-ui/components/Dialog/Dialog.tsx index ce9f86b052..e85f160ea4 100644 --- a/packages/circuit-ui/components/Dialog/Dialog.tsx +++ b/packages/circuit-ui/components/Dialog/Dialog.tsx @@ -57,7 +57,7 @@ export interface DialogProps /** * a function that returns the content of the dialog. */ - children?: () => ReactNode; + children?: ({ onClose }: { onClose?: DialogProps['onClose'] }) => ReactNode; /** * Text label for the close button for screen readers. * Important for accessibility. @@ -255,7 +255,9 @@ export const Dialog = forwardRef( {closeButtonLabel} - {open &&
{children?.()}
} + {open && ( +
{children?.({ onClose })}
+ )} ); diff --git a/packages/circuit-ui/components/Dialog/ModalContext.tsx b/packages/circuit-ui/components/Dialog/ModalContext.tsx index a8dadbfec4..c333cf5c6d 100644 --- a/packages/circuit-ui/components/Dialog/ModalContext.tsx +++ b/packages/circuit-ui/components/Dialog/ModalContext.tsx @@ -23,10 +23,11 @@ import { useState, } from 'react'; +import type { Optional } from '../../types/util.js'; + import type { DialogProps } from './Dialog.js'; import type { ModalDialogComponent } from './createUseModalDialog.js'; -type Optional = Pick, K> & Omit; export type SetModalArgs = Optional; // keep initial state compatible with the old version of this component