Avoid setting focus if input element is not displayed.