Focus on autofocus attr in popup

Focuses on an input field with the autofocus attribute defined,
otherwise focuses on the 1st or a button