@@ -27,11 +27,11 @@ export interface PortalContextProps {
27
27
inTriggerContext : boolean ; // 仅处理 trigger 上下文的 portal
28
28
}
29
29
const PortalContextKey : InjectionKey < PortalContextProps > = Symbol ( 'PortalContextKey' ) ;
30
- export const useProvidePortal = ( instance : any ) => {
30
+ export const useProvidePortal = ( instance : any , config = { inTriggerContext : true } ) => {
31
31
provide ( PortalContextKey , {
32
- inTriggerContext : true ,
32
+ inTriggerContext : config . inTriggerContext ,
33
33
shouldRender : computed ( ( ) => {
34
- const { sPopupVisible, popupRef, forceRender, autoDestroy } = instance ;
34
+ const { sPopupVisible, popupRef, forceRender, autoDestroy } = instance || { } ;
35
35
// if (popPortal) return true;
36
36
let shouldRender = false ;
37
37
if ( sPopupVisible || popupRef || forceRender ) {
@@ -46,6 +46,7 @@ export const useProvidePortal = (instance: any) => {
46
46
} ;
47
47
48
48
export const useInjectPortal = ( ) => {
49
+ useProvidePortal ( { } , { inTriggerContext : false } ) ;
49
50
const portalContext = inject ( PortalContextKey , {
50
51
shouldRender : computed ( ( ) => false ) ,
51
52
inTriggerContext : false ,
0 commit comments