Skip to content

Commit

Permalink
fix(ui5-popover): ensure offset from window borders (#1690)
Browse files Browse the repository at this point in the history
By design the popover should have a minimum 10 px offset from the window borders.

FIXES: #1656
  • Loading branch information
ilhan007 authored May 27, 2020
1 parent 934b4df commit b673a0c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/main/src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ class Popover extends Popup {
return PopoverTemplate;
}

static get MIN_OFFSET() {
return 10; // px
}

isOpenerClicked(event) {
const target = event.target;
return target === this._opener || (target.getFocusDomRef && target.getFocusDomRef() === this._opener);
Expand Down Expand Up @@ -404,12 +408,15 @@ class Popover extends Popup {

this._oldPlacement = placement;

const popoverOnLeftBorder = this._left === 0;
const popoverOnTopBorder = this._top === 0;

this.actualPlacementType = placement.placementType;
this.arrowTranslateX = placement.arrowX;
this.arrowTranslateY = placement.arrowY;
this.arrowTranslateX = popoverOnLeftBorder ? placement.arrowX - Popover.MIN_OFFSET : placement.arrowX;
this.arrowTranslateY = popoverOnTopBorder ? placement.arrowY - Popover.MIN_OFFSET : placement.arrowY;

this.style.left = `${this._left}px`;
this.style.top = `${this._top}px`;
this.style.left = `${popoverOnLeftBorder ? Popover.MIN_OFFSET : this._left}px`;
this.style.top = `${popoverOnTopBorder ? Popover.MIN_OFFSET : this._top}px`;
this.show();

if (stretching && this._width) {
Expand Down

0 comments on commit b673a0c

Please sign in to comment.