automatically closing fields when clicking out or in other element