Fix tooltip misplacement with "auto top"

Fixes #14322.
Closes #14581.