Fix focus edge cases

Preview needs to have focus after hide-code¸ even if code was
just updated. Dialog input text fields need to retain focus when
opened.