changed autofocus to only applied when non-modal.

changed autofocus to only applied when non-modal.