Update tooltip placement logic to try to ensure it's within the viewport.