Put tooltip/popover on bottom if there is not enough space on top

Currently, the tooltip/popover is not visible if the field is on top of the page. With this PR, the tooltip/popover is displayed below the input if there is not enough space above.