issue #4861, fix a problem when layout focus loops