Sidebar behavior when navigating by keyboard, some refactoring