@@ -27,11 +27,11 @@ export interface PortalContextProps {
2727 inTriggerContext : boolean ; // 仅处理 trigger 上下文的 portal
2828}
2929const 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
4848export const useInjectPortal = ( ) => {
49+ useProvidePortal ( { } , { inTriggerContext : false } ) ;
4950 const portalContext = inject ( PortalContextKey , {
5051 shouldRender : computed ( ( ) => false ) ,
5152 inTriggerContext : false ,
0 commit comments