diff --git a/packages/components/src/popover/utils.js b/packages/components/src/popover/utils.js index 55ee240998ace..6f566916c66c7 100644 --- a/packages/components/src/popover/utils.js +++ b/packages/components/src/popover/utils.js @@ -108,10 +108,13 @@ export function computePopoverXAxisPosition( ? leftAlignment.contentWidth : rightAlignment.contentWidth; + // Limit width of the content to the viewport width if ( width > window.innerWidth ) { contentWidth = window.innerWidth; } + // If we can't find any alignment options that could fit + // our content, then let's fallback to the center of the viewport. if ( chosenWidth !== width ) { chosenXAxis = 'center'; centerAlignment.popoverLeft = window.innerWidth / 2;