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 | 1 | <template> |
2 | - <Modal v-bind="getBindValue"> | |
2 | + <Modal v-bind="getBindValue" @cancel="handleCancel"> | |
3 | 3 | <template #closeIcon v-if="!$slots.closeIcon"> |
4 | 4 | <ModalClose |
5 | 5 | :canFullscreen="getProps.canFullscreen" |
... | ... | @@ -72,6 +72,7 @@ |
72 | 72 | import { basicProps } from './props'; |
73 | 73 | import { useFullScreen } from './hooks/useModalFullScreen'; |
74 | 74 | import { omit } from 'lodash-es'; |
75 | + import { useDesign } from '/@/hooks/web/useDesign'; | |
75 | 76 | |
76 | 77 | export default defineComponent({ |
77 | 78 | name: 'BasicModal', |
... | ... | @@ -83,6 +84,7 @@ |
83 | 84 | const visibleRef = ref(false); |
84 | 85 | const propsRef = ref<Partial<ModalProps> | null>(null); |
85 | 86 | const modalWrapperRef = ref<any>(null); |
87 | + const { prefixCls } = useDesign('basic-modal'); | |
86 | 88 | |
87 | 89 | // modal Bottom and top height |
88 | 90 | const extHeightRef = ref(0); |
... | ... | @@ -175,7 +177,8 @@ |
175 | 177 | // 取消事件 |
176 | 178 | async function handleCancel(e: Event) { |
177 | 179 | e?.stopPropagation(); |
178 | - | |
180 | + // 过滤自定义关闭按钮的空白区域 | |
181 | + if ((e.target as HTMLElement)?.classList?.contains(prefixCls + '-close--custom')) return; | |
179 | 182 | if (props.closeFunc && isFunction(props.closeFunc)) { |
180 | 183 | const isClose: boolean = await props.closeFunc(); |
181 | 184 | visibleRef.value = !isClose; | ... | ... |