This is an age-old problem on the web. Sometimes when you open UI elements, they need to be edge-aware to prevent the content from triggering weird scrollbars, or worse, cutting off content.
https://css-tricks.com/can-css-prevent-tooltips-from-overflowing/