Commit 2346a90c0839a24773c8599a0e98f85e3bf92373
1 parent
6544f84b
fix(modal): `maskClosable` and `Esc` take no effect
修复BasicModal按Esc和点击遮罩无法关闭的问题 fixed: #1203
Showing
1 changed file
with
5 additions
and
2 deletions
src/components/Modal/src/BasicModal.vue
1 | <template> | 1 | <template> |
2 | - <Modal v-bind="getBindValue"> | 2 | + <Modal v-bind="getBindValue" @cancel="handleCancel"> |
3 | <template #closeIcon v-if="!$slots.closeIcon"> | 3 | <template #closeIcon v-if="!$slots.closeIcon"> |
4 | <ModalClose | 4 | <ModalClose |
5 | :canFullscreen="getProps.canFullscreen" | 5 | :canFullscreen="getProps.canFullscreen" |
@@ -72,6 +72,7 @@ | @@ -72,6 +72,7 @@ | ||
72 | import { basicProps } from './props'; | 72 | import { basicProps } from './props'; |
73 | import { useFullScreen } from './hooks/useModalFullScreen'; | 73 | import { useFullScreen } from './hooks/useModalFullScreen'; |
74 | import { omit } from 'lodash-es'; | 74 | import { omit } from 'lodash-es'; |
75 | + import { useDesign } from '/@/hooks/web/useDesign'; | ||
75 | 76 | ||
76 | export default defineComponent({ | 77 | export default defineComponent({ |
77 | name: 'BasicModal', | 78 | name: 'BasicModal', |
@@ -83,6 +84,7 @@ | @@ -83,6 +84,7 @@ | ||
83 | const visibleRef = ref(false); | 84 | const visibleRef = ref(false); |
84 | const propsRef = ref<Partial<ModalProps> | null>(null); | 85 | const propsRef = ref<Partial<ModalProps> | null>(null); |
85 | const modalWrapperRef = ref<any>(null); | 86 | const modalWrapperRef = ref<any>(null); |
87 | + const { prefixCls } = useDesign('basic-modal'); | ||
86 | 88 | ||
87 | // modal Bottom and top height | 89 | // modal Bottom and top height |
88 | const extHeightRef = ref(0); | 90 | const extHeightRef = ref(0); |
@@ -175,7 +177,8 @@ | @@ -175,7 +177,8 @@ | ||
175 | // 取消事件 | 177 | // 取消事件 |
176 | async function handleCancel(e: Event) { | 178 | async function handleCancel(e: Event) { |
177 | e?.stopPropagation(); | 179 | e?.stopPropagation(); |
178 | - | 180 | + // 过滤自定义关闭按钮的空白区域 |
181 | + if ((e.target as HTMLElement)?.classList?.contains(prefixCls + '-close--custom')) return; | ||
179 | if (props.closeFunc && isFunction(props.closeFunc)) { | 182 | if (props.closeFunc && isFunction(props.closeFunc)) { |
180 | const isClose: boolean = await props.closeFunc(); | 183 | const isClose: boolean = await props.closeFunc(); |
181 | visibleRef.value = !isClose; | 184 | visibleRef.value = !isClose; |