Resize the popup if the viewport does not permit, rather than overflowing the viewport.