Correctly selects arrow placement for a tooltip

Fixes #13696.
Fixes #13696.
Fixes #14197.
Closes #13718.