File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -345,8 +345,12 @@ export default mixins(classPrefixMixins, getAttachConfigMixins('popup')).extend(
345345 // 子元素存在打开的 popup 时,ui 可能重叠,而 dom 节点多是并列关系
346346 // 需要做碰撞检测去阻止父级 popup 关闭
347347 if ( this . visibleState > 1 ) {
348- const rect = ( this . $refs . popper as HTMLElement ) . getBoundingClientRect ( ) ;
349- if ( ev . x > rect . x && ev . x < rect . x + rect . width && ev . y > rect . y && ev . y < rect . y + rect . height ) return ;
348+ // 优先使用实际可见的 overlay 容器进行碰撞检测;
349+ // 在某些场景下(如菜单子菜单弹层),popper 容器可能为 0x0(overlay 采用绝对定位脱离文档流),
350+ // 这会导致用 popper 计算的矩形始终为 0x0,从而误判离开范围,导致父级过早关闭。
351+ const rectTarget = ( this . $refs . overlay as HTMLElement ) || ( this . $refs . popper as HTMLElement ) ;
352+ const rect = rectTarget ?. getBoundingClientRect ?.( ) ;
353+ if ( rect && ev . x > rect . x && ev . x < rect . x + rect . width && ev . y > rect . y && ev . y < rect . y + rect . height ) return ;
350354 }
351355 this . mouseInRange = false ;
352356 this . handleClose ( { } ) ;
You can’t perform that action at this time.
0 commit comments