Preferred side, then it flips, then it shifts. Measured when it opens

A popover is not a tooltip: it opens on a CLICK, you can Tab into it, and it closes on Escape with focus going back to the button. If the content has no controls in it, use a tooltip instead — a button inside a tooltip is unreachable.