Fix saving/restoring of previous item focus for popups
You can't save the focus after the popup/dialog has been created,
at that stage the dialog has focus already,
you need to do it before creating it.
Approved by ubuntu-sdk-build-bot, Zsombor Egri.