Skip to content

Commit f6d1b84

Browse files
committed
fix: modal cannot open in dropdown, close #5139
1 parent 3d3dcd5 commit f6d1b84

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

components/vc-dialog/DialogWrap.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { IDialogChildProps } from './IDialogPropTypes';
33
import getDialogPropTypes from './IDialogPropTypes';
44
import Portal from '../_util/PortalWrapper';
55
import { defineComponent, ref, watch } from 'vue';
6+
import { useProvidePortal } from '../vc-trigger/context';
67
const IDialogPropTypes = getDialogPropTypes();
78
const DialogWrap = defineComponent({
89
name: 'DialogWrap',
@@ -13,6 +14,7 @@ const DialogWrap = defineComponent({
1314
},
1415
setup(props, { attrs, slots }) {
1516
const animatedVisible = ref(props.visible);
17+
useProvidePortal({}, { inTriggerContext: false });
1618
watch(
1719
() => props.visible,
1820
() => {

components/vc-trigger/context.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export interface PortalContextProps {
2727
inTriggerContext: boolean; // 仅处理 trigger 上下文的 portal
2828
}
2929
const PortalContextKey: InjectionKey<PortalContextProps> = Symbol('PortalContextKey');
30-
export const useProvidePortal = (instance: any) => {
30+
export const useProvidePortal = (instance: any, config = { inTriggerContext: true }) => {
3131
provide(PortalContextKey, {
32-
inTriggerContext: true,
32+
inTriggerContext: config.inTriggerContext,
3333
shouldRender: computed(() => {
34-
const { sPopupVisible, popupRef, forceRender, autoDestroy } = instance;
34+
const { sPopupVisible, popupRef, forceRender, autoDestroy } = instance || {};
3535
// if (popPortal) return true;
3636
let shouldRender = false;
3737
if (sPopupVisible || popupRef || forceRender) {
@@ -46,6 +46,7 @@ export const useProvidePortal = (instance: any) => {
4646
};
4747

4848
export const useInjectPortal = () => {
49+
useProvidePortal({}, { inTriggerContext: false });
4950
const portalContext = inject(PortalContextKey, {
5051
shouldRender: computed(() => false),
5152
inTriggerContext: false,

0 commit comments

Comments
 (0)