From 85f791b157149152ed71445e8a744d1934c7cd3b Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 29 Nov 2024 09:59:58 +0100 Subject: [PATCH 1/4] expose modal props --- packages/@mantine/modals/src/ModalsProvider.tsx | 1 + packages/@mantine/modals/src/context.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/@mantine/modals/src/ModalsProvider.tsx b/packages/@mantine/modals/src/ModalsProvider.tsx index 5fa59d7925..00cc88966a 100644 --- a/packages/@mantine/modals/src/ModalsProvider.tsx +++ b/packages/@mantine/modals/src/ModalsProvider.tsx @@ -166,6 +166,7 @@ export function ModalsProvider({ children, modalProps, labels, modals }: ModalsP }); const ctx: ModalsContextProps = { + modalProps, modals: state.modals, openModal, openConfirmModal, diff --git a/packages/@mantine/modals/src/context.ts b/packages/@mantine/modals/src/context.ts index 2445481948..8cb6898349 100644 --- a/packages/@mantine/modals/src/context.ts +++ b/packages/@mantine/modals/src/context.ts @@ -24,6 +24,7 @@ export type ModalState = | { id: string; props: OpenContextModal; type: 'context'; ctx: string }; export interface ModalsContextProps { + modalProps?: ModalSettings, modals: ModalState[]; openModal: (props: ModalSettings) => string; openConfirmModal: (props: OpenConfirmModal) => string; From 14bee00617b0273ced613be504bd59c921d1f963 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 29 Nov 2024 10:06:39 +0100 Subject: [PATCH 2/4] minor refactor --- packages/@mantine/modals/src/ModalsProvider.tsx | 2 +- packages/@mantine/modals/src/context.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@mantine/modals/src/ModalsProvider.tsx b/packages/@mantine/modals/src/ModalsProvider.tsx index 00cc88966a..37a89e08d9 100644 --- a/packages/@mantine/modals/src/ModalsProvider.tsx +++ b/packages/@mantine/modals/src/ModalsProvider.tsx @@ -166,7 +166,7 @@ export function ModalsProvider({ children, modalProps, labels, modals }: ModalsP }); const ctx: ModalsContextProps = { - modalProps, + modalProps: modalProps || {}, modals: state.modals, openModal, openConfirmModal, diff --git a/packages/@mantine/modals/src/context.ts b/packages/@mantine/modals/src/context.ts index 8cb6898349..0ceb7242e9 100644 --- a/packages/@mantine/modals/src/context.ts +++ b/packages/@mantine/modals/src/context.ts @@ -24,7 +24,7 @@ export type ModalState = | { id: string; props: OpenContextModal; type: 'context'; ctx: string }; export interface ModalsContextProps { - modalProps?: ModalSettings, + modalProps: ModalSettings, modals: ModalState[]; openModal: (props: ModalSettings) => string; openConfirmModal: (props: OpenConfirmModal) => string; From a95fff5d042849aedb0c82d9ac613493164838ad Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 29 Nov 2024 10:13:25 +0100 Subject: [PATCH 3/4] formatting --- packages/@mantine/modals/src/context.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@mantine/modals/src/context.ts b/packages/@mantine/modals/src/context.ts index 0ceb7242e9..0ff6195e75 100644 --- a/packages/@mantine/modals/src/context.ts +++ b/packages/@mantine/modals/src/context.ts @@ -24,7 +24,7 @@ export type ModalState = | { id: string; props: OpenContextModal; type: 'context'; ctx: string }; export interface ModalsContextProps { - modalProps: ModalSettings, + modalProps: ModalSettings; modals: ModalState[]; openModal: (props: ModalSettings) => string; openConfirmModal: (props: OpenConfirmModal) => string; From 675fc8d4b3ee9db5f22755b14ae74d174449d971 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 29 Nov 2024 13:49:51 +0100 Subject: [PATCH 4/4] Update ModalsProvider.tsx --- packages/@mantine/modals/src/ModalsProvider.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@mantine/modals/src/ModalsProvider.tsx b/packages/@mantine/modals/src/ModalsProvider.tsx index 37a89e08d9..a594cc2633 100644 --- a/packages/@mantine/modals/src/ModalsProvider.tsx +++ b/packages/@mantine/modals/src/ModalsProvider.tsx @@ -148,8 +148,8 @@ export function ModalsProvider({ children, modalProps, labels, modals }: ModalsP ); const updateContextModal = useCallback( - (payload: { modalId: string } & Partial>) => { - dispatch({ type: 'UPDATE', modalId: payload.modalId, newProps: payload }); + ({ modalId, ...newProps }: { modalId: string } & Partial>) => { + dispatch({ type: 'UPDATE', modalId, newProps }); }, [dispatch] );