Skip to content

Commit

Permalink
Limit width and fallback to center if none of the options fit
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Dec 10, 2020
1 parent 63c9356 commit 780edbf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/components/src/popover/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@ export function computePopoverXAxisPosition(
chosenXAxis === 'left'
? leftAlignment.contentWidth
: rightAlignment.contentWidth;
contentWidth = chosenWidth !== width ? chosenWidth : null;

if ( width > window.innerWidth ) {
contentWidth = window.innerWidth;
}

if ( chosenWidth !== width ) {
chosenXAxis = 'center';
centerAlignment.popoverLeft = window.innerWidth / 2;
}
}
}

Expand Down

0 comments on commit 780edbf

Please sign in to comment.