@@ -529,9 +529,7 @@ class Popover extends Popup {
529
529
530
530
let maxContentHeight = Math . round ( maxHeight ) ;
531
531
532
- const hasHeader = this . header . length || this . headerText ;
533
-
534
- if ( hasHeader ) {
532
+ if ( this . _displayHeader ) {
535
533
const headerDomRef = this . shadowRoot . querySelector ( ".ui5-popup-header-root" )
536
534
|| this . shadowRoot . querySelector ( ".ui5-popup-header-text" ) ;
537
535
@@ -542,9 +540,7 @@ class Popover extends Popup {
542
540
543
541
this . _maxContentHeight = maxContentHeight ;
544
542
545
- const arrowXCentered = this . horizontalAlign === PopoverHorizontalAlign . Center || this . horizontalAlign === PopoverHorizontalAlign . Stretch ;
546
- const arrowTranslateX = isVertical && arrowXCentered ? targetRect . left + targetRect . width / 2 - left - popoverSize . width / 2 : 0 ;
547
- const arrowTranslateY = ! isVertical ? targetRect . top + targetRect . height / 2 - top - popoverSize . height / 2 : 0 ;
543
+ let arrowPos = this . getArrowPosition ( targetRect , popoverSize , left , isVertical ) ;
548
544
549
545
if ( this . _left === undefined || Math . abs ( this . _left - left ) > 1.5 ) {
550
546
this . _left = Math . round ( left ) ;
@@ -555,14 +551,50 @@ class Popover extends Popup {
555
551
}
556
552
557
553
return {
558
- arrowX : Math . round ( arrowTranslateX ) ,
559
- arrowY : Math . round ( arrowTranslateY ) ,
554
+ arrowX : arrowPos . x ,
555
+ arrowY : arrowPos . y ,
560
556
top : this . _top ,
561
557
left : this . _left ,
562
558
placementType,
563
559
} ;
564
560
}
565
561
562
+ /**
563
+ * Calculates the position for the arrow.
564
+ * @private
565
+ * @param targetRect BoundingClientRect of the target element
566
+ * @param popoverSize Width and height of the popover
567
+ * @param left Left offset of the popover
568
+ * @param isVertical if the popover is positioned vertically to the target element
569
+ * @returns {{x: number, y: number} } Arrow's coordinates
570
+ */
571
+ getArrowPosition ( targetRect , popoverSize , left , isVertical ) {
572
+ let arrowXCentered = this . horizontalAlign === PopoverHorizontalAlign . Center || this . horizontalAlign === PopoverHorizontalAlign . Stretch ;
573
+
574
+ if ( this . horizontalAlign === PopoverHorizontalAlign . Right && left <= targetRect . left ) {
575
+ arrowXCentered = true ;
576
+ }
577
+
578
+ if ( this . horizontalAlign === PopoverHorizontalAlign . Left && left + popoverSize . width >= targetRect . left + targetRect . width ) {
579
+ arrowXCentered = true ;
580
+ }
581
+
582
+ let arrowTranslateX = 0 ;
583
+ if ( isVertical && arrowXCentered ) {
584
+ arrowTranslateX = targetRect . left + targetRect . width / 2 - left - popoverSize . width / 2 ;
585
+ }
586
+
587
+ let arrowTranslateY = 0 ;
588
+ if ( ! isVertical ) {
589
+ arrowTranslateY = targetRect . top + targetRect . height / 2 - top - popoverSize . height / 2 ;
590
+ }
591
+
592
+ return {
593
+ x : Math . round ( arrowTranslateX ) ,
594
+ y : Math . round ( arrowTranslateY ) ,
595
+ } ;
596
+ }
597
+
566
598
/**
567
599
* Fallbacks to new placement, prioritizing <code>Left</code> and <code>Right</code> placements.
568
600
* @private
0 commit comments