@@ -572,8 +572,13 @@ export class MenuElement {
572572 const rootElement = this . _rootElement ;
573573 // const element = table.getElement();
574574 const element = table . internalProps . menu . parentElement ?? table . getElement ( ) ;
575- const { width : containerWidth , left : containerLeft , top : containerTop } = element . getBoundingClientRect ( ) ;
576- const { x : rootLeft , y : rootTop , width : rootWidth } = rootElement . getBoundingClientRect ( ) ;
575+ const {
576+ width : containerWidth ,
577+ height : containerHeight ,
578+ left : containerLeft ,
579+ top : containerTop
580+ } = element . getBoundingClientRect ( ) ;
581+ const { x : rootLeft , y : rootTop , width : rootWidth , height : rootHeight } = rootElement . getBoundingClientRect ( ) ;
577582
578583 if ( secondElement ) {
579584 // if (secondElement.parentElement !== rootElement) {
@@ -589,12 +594,20 @@ export class MenuElement {
589594 secondElement . style . maxWidth = `${ maxWidth } px` ;
590595 //计算弹出框的宽度
591596 const secondElementWidth = secondElement . clientWidth ;
592- // const secondElementHeight = secondElement.clientHeight;
597+ const secondElementHeight = secondElement . clientHeight ;
593598
594599 const secondElementTop = y - 4 - containerTop ;
595600 const secondElementLeft = x - containerLeft ;
596601
597- secondElement . style . top = `${ secondElementTop } px` ;
602+ let topStyle = secondElementTop ;
603+ // 判断如果超出下范围则靠上边显示
604+ if ( topStyle + secondElementHeight > containerHeight ) {
605+ const secondElementItem = secondElement . firstElementChild ;
606+ topStyle = topStyle - secondElementHeight + secondElementItem . clientHeight + 4 ;
607+ }
608+
609+ secondElement . style . top = `${ topStyle } px` ;
610+
598611 let leftStyle = secondElementLeft ;
599612
600613 // 判断如果超出右范围则靠左边显示
0 commit comments