From 871113e34f12251451f5c7c536f99c4b54ee2dd2 Mon Sep 17 00:00:00 2001 From: Hooray <304327508@qq.com> Date: Wed, 5 Feb 2025 10:04:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96`FaDrawer`/`FaModal`=E9=81=AE?= =?UTF-8?q?=E7=BD=A9=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/components/FaDrawer/index.vue | 14 +++++++-- .../FaDrawer/sheet/SheetContent.vue | 29 +++++++++++++++---- .../FaModal/dialog/DialogContent.vue | 29 +++++++++++++++---- src/ui/components/FaModal/index.vue | 14 +++++++-- 4 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/ui/components/FaDrawer/index.vue b/src/ui/components/FaDrawer/index.vue index 4727cf6a..cd863987 100644 --- a/src/ui/components/FaDrawer/index.vue +++ b/src/ui/components/FaDrawer/index.vue @@ -73,6 +73,9 @@ const emits = defineEmits<{ 'cancel': [] }>() +const id = useId() +provide('DrawerId', id) + const isOpen = ref(props.modelValue) watch(() => props.modelValue, (newValue) => { @@ -106,14 +109,16 @@ function handleFocusOutside(e: Event) { } function handleClickOutside(e: Event) { - if (!props.closeOnClickOverlay) { + if (!props.closeOnClickOverlay || (e.target as HTMLElement).dataset.drawerId !== id) { e.preventDefault() + e.stopPropagation() } } function handleEscapeKeyDown(e: KeyboardEvent) { if (!props.closeOnPressEscape) { e.preventDefault() + e.stopPropagation() } } @@ -128,12 +133,15 @@ function handleAnimationEnd() {