Skip to content

Commit

Permalink
add/2793: Only take padding into account when using the anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-james committed Nov 2, 2017
1 parent 20fa7fb commit bbae623
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions components/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Popover extends Component {
const isLeft = 'left' === xAxis;
const isRight = 'right' === xAxis;
let rect;
let topOffset = 0;
if ( range ) {
const rects = range.getClientRects();
if ( isLeft ) {
Expand All @@ -155,12 +156,12 @@ class Popover extends Component {
}
} else {
rect = anchor.parentNode.getBoundingClientRect();
}
// Offset top positioning by padding
const { paddingTop, paddingBottom } = window.getComputedStyle( anchor.parentNode );
let topOffset = parseInt( isTop ? paddingTop : paddingBottom, 10 );
if ( ! isTop ) {
topOffset *= -1;
// Offset top positioning by padding
const { paddingTop, paddingBottom } = window.getComputedStyle( anchor.parentNode );
topOffset = parseInt( isTop ? paddingTop : paddingBottom, 10 );
if ( ! isTop ) {
topOffset *= -1;
}
}

if ( isRight ) {
Expand Down

0 comments on commit bbae623

Please sign in to comment.