refactor 'required-on-focus' code