From c81c1794cf7ed2965da5bf2c349dfbb56382aef6 Mon Sep 17 00:00:00 2001 From: vben Date: Wed, 18 Sep 2024 22:35:50 +0800 Subject: [PATCH] fix: the onOpenChange event for the modal component does not work as expected --- internal/vite-config/src/config/application.ts | 1 + packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts | 8 ++++---- packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/vite-config/src/config/application.ts b/internal/vite-config/src/config/application.ts index 184a8f190fe..c680939967b 100644 --- a/internal/vite-config/src/config/application.ts +++ b/internal/vite-config/src/config/application.ts @@ -112,6 +112,7 @@ function createCssOptions(injectGlobalScss = true) { } return content; }, + api: 'modern-compiler', }, } : {}, diff --git a/packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts b/packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts index dc4fb9225f4..c3ff263b06a 100644 --- a/packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts +++ b/packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts @@ -54,10 +54,10 @@ export function useVbenDrawer< ...options, } as DrawerApiOptions; - // mergedOptions.onOpenChange = (isOpen: boolean) => { - // options.onOpenChange?.(isOpen); - // injectData.options?.onOpenChange?.(isOpen); - // }; + mergedOptions.onOpenChange = (isOpen: boolean) => { + options.onOpenChange?.(isOpen); + injectData.options?.onOpenChange?.(isOpen); + }; const api = new DrawerApi(mergedOptions); const extendedApi: ExtendedDrawerApi = api as never; diff --git a/packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts b/packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts index 23a52f0e8b5..f972530def4 100644 --- a/packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts +++ b/packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts @@ -58,10 +58,10 @@ export function useVbenModal( ...options, } as ModalApiOptions; - // mergedOptions.onOpenChange = (isOpen: boolean) => { - // options.onOpenChange?.(isOpen); - // injectData.options?.onOpenChange?.(isOpen); - // }; + mergedOptions.onOpenChange = (isOpen: boolean) => { + options.onOpenChange?.(isOpen); + injectData.options?.onOpenChange?.(isOpen); + }; const api = new ModalApi(mergedOptions); const extendedApi: ExtendedModalApi = api as never;