From 4b3d2d21ede27ca2c194d7bbd5b4a4adc7b4e3e9 Mon Sep 17 00:00:00 2001 From: aonoa <32682251+aonoa@users.noreply.github.com> Date: Sun, 22 Sep 2024 20:38:01 +0800 Subject: [PATCH] fix: Clear the input box when closing the search (#4467) Signed-off-by: aonoa <1991849113@qq.com> --- .../src/widgets/global-search/global-search.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/effects/layouts/src/widgets/global-search/global-search.vue b/packages/effects/layouts/src/widgets/global-search/global-search.vue index 017bc329968..ae002622f3d 100644 --- a/packages/effects/layouts/src/widgets/global-search/global-search.vue +++ b/packages/effects/layouts/src/widgets/global-search/global-search.vue @@ -30,16 +30,21 @@ const props = withDefaults( }, ); +const keyword = ref(''); +const searchInputRef = ref(); + const [Modal, modalApi] = useVbenModal({ onCancel() { modalApi.close(); }, + onOpenChange(isOpen: boolean) { + if (!isOpen) { + keyword.value = ''; + } + }, }); const open = modalApi.useStore((state) => state.isOpen); -const keyword = ref(''); -const searchInputRef = ref(); - function handleClose() { modalApi.close(); keyword.value = '';