From 3c1c6cb0b0e7303ece49c4ec7cba132fcdef7c20 Mon Sep 17 00:00:00 2001 From: zhangxulong Date: Tue, 8 Oct 2024 15:34:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E3=80=81=E6=8A=BD=E5=B1=89=E9=85=8D=E7=BD=AE=E4=BA=86?= =?UTF-8?q?closeOnOutside=EF=BC=8C=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E7=B1=BB=E5=9E=8B=E7=9A=84=E8=A1=A8=E5=8D=95=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=90=8E=E6=95=B4=E4=B8=AA=E5=BC=B9=E7=AA=97=E5=85=B3?= =?UTF-8?q?=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/Drawer.tsx | 7 +++++-- packages/amis-ui/src/components/Modal.tsx | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/amis-ui/src/components/Drawer.tsx b/packages/amis-ui/src/components/Drawer.tsx index 66e053c2c..eb8392710 100644 --- a/packages/amis-ui/src/components/Drawer.tsx +++ b/packages/amis-ui/src/components/Drawer.tsx @@ -44,6 +44,7 @@ export interface DrawerProps { onEntered?: () => void; drawerClassName?: string; drawerMaskClassName?: string; + mobileUI?: boolean; } export interface DrawerState {} const fadeStyles: { @@ -168,7 +169,7 @@ export class Drawer extends React.Component { @autobind handleRootMouseDownCapture(e: MouseEvent) { const target = e.target as HTMLElement; - const {closeOnOutside, classPrefix: ns} = this.props; + const {closeOnOutside, classPrefix: ns, mobileUI} = this.props; const isLeftButton = (e.button === 1 && window.event !== null) || e.button === 0; @@ -177,7 +178,9 @@ export class Drawer extends React.Component { closeOnOutside && target && this.modalDom && - ((!this.modalDom.contains(target) && !target.closest('[role=dialog]')) || + ((!mobileUI && + !this.modalDom.contains(target) && + !target.closest('[role=dialog]')) || (target.matches(`.${ns}Drawer-overlay`) && target.parentElement === this.modalDom)) ); // 干脆过滤掉来自弹框里面的点击 diff --git a/packages/amis-ui/src/components/Modal.tsx b/packages/amis-ui/src/components/Modal.tsx index 4a3c25455..8b45d237c 100644 --- a/packages/amis-ui/src/components/Modal.tsx +++ b/packages/amis-ui/src/components/Modal.tsx @@ -270,7 +270,7 @@ export class Modal extends React.Component { @autobind handleRootMouseDownCapture(e: MouseEvent) { const target = e.target as HTMLElement; - const {closeOnOutside, classPrefix: ns} = this.props; + const {closeOnOutside, classPrefix: ns, mobileUI} = this.props; const isLeftButton = (e.button === 1 && window.event !== null) || e.button === 0; @@ -279,7 +279,9 @@ export class Modal extends React.Component { closeOnOutside && target && this.modalDom && - ((!this.modalDom.contains(target) && !target.closest('[role=dialog]')) || + ((!mobileUI && + !this.modalDom.contains(target) && + !target.closest('[role=dialog]')) || (target.matches(`.${ns}Modal`) && target === this.modalDom)) ); // 干脆过滤掉来自弹框里面的点击 }